A modern video sharing platform built with Next.js, featuring secure user authentication, video uploads, and a responsive interface.
- Upload videos with custom thumbnails
- Personal dashboard for video management
- Delete videos with ownership verification
- Public video gallery accessible to all users
- Multiple authentication providers (Google, GitHub, Email/Password)
- JWT-based sessions with 30-day expiration
- Password hashing with bcrypt
- Input validation and security headers
- Route protection with middleware
- Responsive design for all devices
- Clean, modern interface
- Real-time upload progress tracking
- Intuitive navigation and user experience
- Frontend: Next.js 14, React 18, TypeScript
- Backend: Next.js API Routes, Node.js
- Database: PostgreSQL with Drizzle ORM
- Authentication: NextAuth.js v4
- File Storage: ImageKit
- Deployment: Vercel-ready
- Node.js 18+
- PostgreSQL database
- ImageKit account
- Google/GitHub OAuth credentials (optional)
-
Clone the repository
git clone <repository-url> cd nextjs-poject
-
Install dependencies
npm install
-
Environment setup Create a
.env.localfile:# Database DATABASE_URL=postgresql://username:password@localhost:5432/database_name # NextAuth NEXTAUTH_SECRET=your_nextauth_secret_key NEXTAUTH_URL=http://localhost:3000 # ImageKit NEXT_PUBLIC_PUBLIC_KEY=your_imagekit_public_key IMAGEKIT_PRIVATE_KEY=your_imagekit_private_key IMAGEKIT_URL_ENDPOINT=your_imagekit_url_endpoint # OAuth (Optional) GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret GITHUB_ID=your_github_client_id GITHUB_SECRET=your_github_client_secret
-
Database setup
# Generate and run migrations npx drizzle-kit generate npx drizzle-kit migrate -
Start development server
npm run dev
Open http://localhost:3000 to view the application.
nextjs-poject/
├── app/ # Next.js App Router
│ ├── api/ # API Routes
│ ├── components/ # Reusable components
│ ├── dashboard/ # User dashboard
│ ├── login/ # Login page
│ ├── register/ # Registration page
│ └── profile/ # User profile
├── db/ # Drizzle database schemas
│ └── schema.ts # Database schema definitions
├── utils/ # Utility functions
├── middleware.ts # NextAuth middleware
├── drizzle.config.ts # Drizzle configuration
└── next.config.ts # Next.js configuration
- Create a PostgreSQL database (local or cloud provider like Supabase, Neon, etc.)
- Update
DATABASE_URLin your environment variables - Run migrations to create the database schema:
npx drizzle-kit generate npx drizzle-kit migrate
- Sign up at ImageKit.io
- Get your public key, private key, and URL endpoint
- Update the ImageKit environment variables
- Google OAuth: Create credentials in Google Cloud Console
- GitHub OAuth: Create OAuth App in GitHub Developer Settings
- Add appropriate callback URLs for each provider
- Browse videos on the homepage
- Register or login to upload videos
- Use the dashboard to manage your videos
- Upload videos with titles, descriptions, and thumbnails
- Delete your own videos when needed
- API routes are located in
app/api/ - Database schemas are in
db/schema.ts - Components are in
app/components/ - Add new pages in the
app/directory
GET /api/video- Fetch all videos or filter by user emailPOST /api/video- Upload a new video (authenticated)DELETE /api/video?id=<videoId>- Delete a video (authenticated, owner only)GET /api/imageKit-auth- Get ImageKit authentication tokens
- JWT-based authentication with NextAuth.js
- Password hashing with bcrypt
- Input validation and sanitization
- Security headers (XSS protection, clickjacking prevention)
- Route protection with middleware
- Ownership verification for video operations
The database schema is defined using Drizzle ORM in db/schema.ts. The schema includes:
-
users table: Stores user authentication data
- id (UUID)
- email (unique)
- password (hashed)
- createdAt, updatedAt timestamps
-
videos table: Stores video metadata
- id (UUID)
- title, description
- videoUrl, thumbnailUrl
- controllers (boolean)
- ownerId, ownerName, ownerEmail
- transformation (height, width, quality)
- createdAt, updatedAt timestamps
Run npx drizzle-kit studio to view and manage your database schema visually.
- Push code to GitHub
- Connect repository to Vercel
- Add environment variables in Vercel dashboard
- Deploy
NEXTAUTH_URL=https://your-domain.com
DATABASE_URL=your_production_postgresql_connection_string
NEXTAUTH_SECRET=your_production_secret- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
This project is licensed under the MIT License.
For issues and questions:
- Check existing issues
- Create a new issue with detailed information
- Include error messages and reproduction steps
Built with Next.js, NextAuth.js, PostgreSQL, Drizzle ORM, and ImageKit.