Collaborative music streaming: host a session, share a link, friends add songs and vote. The most upvoted track plays next.
- Google sign-in via NextAuth
- Host session with short join code
- Add YouTube songs by URL (auto title/thumbnail)
- Live queue updates via polling (SWR)
- Upvote to reorder queue dynamically
- Next.js (App Router)
- Prisma (PostgreSQL)
- NextAuth (Google)
- SWR
- Install dependencies
pnpm install- Configure environment
Create
app/.env.localwith:
- Prisma
npx prisma generate
npx prisma migrate dev --name init- Run
pnpm devpnpm dev– start dev serverpnpm build– buildpnpm start– start production server (after build)pnpm prisma:generate– Prisma client generatepnpm prisma:migrate– Run pending migrations in dev
Provide the same env vars in your hosting platform:
- DATABASE_URL
- GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET
- NEXTAUTH_URL (your production URL)
- NEXTAUTH_SECRET
Run migrations on deploy (depends on platform), or pre-run locally and ship the DB.
- Voting is implemented as upvote/remove-upvote to keep the model simple. If you need downvotes, add a
Downvotesmodel and sort by (upvotes - downvotes). - Real-time updates use polling (SWR refreshInterval). You can switch to WebSockets/SSE later.