A Next.js application for synchronized video watching with friends and family. Features real-time synchronization, live chat, and private rooms.
Production: https://sync-player-client-new.vercel.app
- 🔐 Google OAuth Authentication - Secure login with NextAuth.js
- 🎬 Synchronized Video Playback - Watch together in real-time
- 💬 Live Chat - Chat while watching
- 🔒 Private Rooms - Create secure viewing sessions
- 🌙 Dark/Light Mode - Theme toggle support
- 📱 Responsive Design - Works on all devices
- Framework: Next.js 15.3.4
- Authentication: NextAuth.js with Google OAuth
- Styling: Tailwind CSS 4.0
- Language: TypeScript
- Deployment: Vercel
- Node.js 18+
- npm or yarn
- Google Cloud Console account (for OAuth)
Create a .env.local file in the root directory:
# NextAuth Configuration
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-super-secret-key-here
# Google OAuth Credentials
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google+ API and Google OAuth2 API
- Go to Credentials → Create Credentials → OAuth 2.0 Client IDs
- Set Application type to Web application
- Add authorized redirect URIs:
- Development:
http://localhost:3000/api/auth/callback/google - Production:
https://your-domain.com/api/auth/callback/google
- Development:
-
Clone the repository
git clone <repository-url> cd sync-player/client
-
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env.local # Edit .env.local with your credentials -
Run the development server
npm run dev
-
Open your browser Navigate to http://localhost:3000
-
Deploy to Vercel
npm run build vercel --prod
-
Set environment variables in Vercel
- Go to your Vercel dashboard
- Select your project → Settings → Environment Variables
- Add all environment variables from
.env.local - Important: Set
NEXTAUTH_URLto your production URL
-
Update Google OAuth settings
- Add your production domain to authorized redirect URIs
- Format:
https://your-domain.com/api/auth/callback/google
When deploying to a new domain or subdomain, follow these steps:
Update your environment variables for the new deployment:
# For new production deployment
NEXTAUTH_URL=https://your-new-domain.com
NEXTAUTH_SECRET=your-secret-key
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret-
Go to Google Cloud Console
- Navigate to Google Cloud Console
- Select your project
-
Update OAuth 2.0 Client
- Go to APIs & Services → Credentials
- Click on your OAuth 2.0 Client ID
- In Authorized redirect URIs, add:
https://your-new-domain.com/api/auth/callback/google - Click Save
- Go to your Vercel dashboard
- Select your project
- Go to Settings → Environment Variables
- Update
NEXTAUTH_URLto your new domain - Redeploy the application
- Set the environment variables in your hosting platform
- Ensure
NEXTAUTH_URLmatches your deployment URL - Redeploy the application
- Visit your new deployment URL
- Click Sign In
- Test the Google OAuth flow
- Verify successful authentication and redirect
-
"Error 400: redirect_uri_mismatch"
- Ensure the redirect URI in Google Console matches exactly:
https://your-domain.com/api/auth/callback/google - Check for trailing slashes and protocol (http vs https)
- Ensure the redirect URI in Google Console matches exactly:
-
"NEXTAUTH_URL environment variable not set"
- Set
NEXTAUTH_URLin your environment variables - For production, use your full domain:
https://your-domain.com
- Set
-
"Invalid client: no registered origin"
- Add your domain to Authorized JavaScript origins in Google Console
- Format:
https://your-domain.com(no trailing slash)
-
Authentication works locally but not in production
- Verify all environment variables are set in production
- Check that
NEXTAUTH_SECRETis set and secure - Ensure Google OAuth is configured for production domain
npm run dev- Start development servernpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLint
src/
├── app/
│ ├── api/auth/[...nextauth]/ # NextAuth API routes
│ ├── auth/signin/ # Custom sign-in page
│ ├── layout.tsx # Root layout with providers
│ └── page.tsx # Home page
├── components/
│ ├── AuthButton.tsx # Authentication button
│ ├── SessionProvider.tsx # NextAuth session provider
│ └── ui/ # UI components
├── hooks/
│ └── useAuth.ts # Authentication hook
├── lib/
│ └── auth.ts # NextAuth configuration
└── sections/
└── home/ # Home page sections
- Fork the repository
- Create a feature branch
- Make your changes
- Test authentication flow
- Submit a pull request
This project is licensed under the MIT License.
- Live Demo: https://sync-player-client-new.vercel.app
- NextAuth.js Documentation: https://next-auth.js.org/
- Google OAuth Setup: https://developers.google.com/identity/protocols/oauth2
Note: Make sure to keep your environment variables secure and never commit them to version control. Always use .env.local for local development and set them through your hosting platform's dashboard for production deployments.