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: MongoDB with Mongoose ODM
- Authentication: NextAuth.js v4
- File Storage: ImageKit
- Deployment: Vercel-ready
- Node.js 18+
- MongoDB 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.local
file:# Database MONGODB_URI=your_mongodb_connection_string # 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
-
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
├── models/ # MongoDB schemas
├── utils/ # Utility functions
├── middleware.ts # NextAuth middleware
└── next.config.ts # Next.js configuration
- Create a MongoDB database (local or MongoDB Atlas)
- Update
MONGODB_URI
in your environment variables
- 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 models are in
models/
- 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
// User Model
interface User {
email: string;
password: string;
createdAt: Date;
updatedAt: Date;
}
// Video Model
interface Video {
title: string;
description: string;
videoUrl: string;
thumbnailUrl: string;
owner: {
id: string;
name?: string;
email: string;
};
createdAt: Date;
updatedAt: Date;
}
- Push code to GitHub
- Connect repository to Vercel
- Add environment variables in Vercel dashboard
- Deploy
NEXTAUTH_URL=https://your-domain.com
MONGODB_URI=your_production_mongodb_uri
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, MongoDB, and ImageKit.