Examples
Practical code examples to help you get started
Page Layout
Create page layouts with App Router
typescript
// app/[locale]/layout.tsx
export default function Layout({ children }) {
return (
<div className="flex min-h-screen flex-col">
<Header />
<main className="flex-1">{children}</main>
<Footer />
</div>
)
}
Database Query
Query data with Prisma
typescript
// lib/db.ts
import { db } from "@/lib/db"
const posts = await db.post.findMany({
where: { status: "PUBLISHED" },
orderBy: { createdAt: "desc" },
include: { author: true },
})
Authentication
Implement user authentication
typescript
// lib/auth/session.ts
import { getCurrentUser } from "@/lib/auth/session"
export default async function Page() {
const user = await getCurrentUser()
if (!user) {
redirect("/login")
}
return <Dashboard user={user} />
}