Design Prisma schema
⏱️ 3-4 hours
model Post {
id String @id @default(cuid())
content String @db.Text
authorId String
author User @relation(fields: [authorId], references: [id])
likes Like[]
comments Comment[]
createdAt DateTime @default(now())
}Model User, Post, Comment, Like
Add relations between models
⚠️ Common Pitfalls:
Add NextAuth.js
⏱️ 4-5 hours
export const authOptions = {
providers: [GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!
})],
adapter: PrismaAdapter(prisma)
}Install next-auth and adapter
Configure OAuth providers
⚠️ Common Pitfalls:
Build post creation form
⏱️ 5-6 hours
const post = await prisma.post.create({
data: {
content,
authorId: session.user.id
}
})Use Server Actions for mutations
Add optimistic updates
⚠️ Common Pitfalls:
Display post feed with infinite scroll
⏱️ 4-5 hours
const posts = await prisma.post.findMany({
take: 10,
skip: cursor,
include: { author: true, _count: { select: { likes: true, comments: true } } },
orderBy: { createdAt: "desc" }
})Use cursor-based pagination
Include author and counts
⚠️ Common Pitfalls:
Add interaction features
⏱️ 3-4 hours
await prisma.like.create({
data: { postId, userId }
})Use unique constraint for likes
Implement optimistic updates
⚠️ Common Pitfalls:
Add live updates with polling
⏱️ 3-4 hours
const { data } = useSWR("/api/posts", fetcher, { refreshInterval: 3000 })Use SWR or React Query
⚠️ Common Pitfalls:
Deploy to Vercel with Postgres
⏱️ 2-3 hours
vercel --prod⚠️ Common Pitfalls: