Next.js 15
React framework for building full-stack web applications with built-in server-side rendering, routing, and performance optimization.
Dependency | Version | Status |
---|---|---|
React | 19.2.0 | Compatible |
TypeScript | 5.9.2 | Compatible |
Node.js | 24.8.0 | Compatible |
Vercel AI SDK | 5.0.48 | Compatible |
Getting Started
Create a new Next.js app in 30 seconds with our verified stack configuration.
# Create new Next.js app with Turbopack
npx create-next-app@latest my-app --turbo
# Navigate to your project
cd my-app
# Start development server
npm run dev
Using React 19.2.0
Integration Patterns
Next.js + Vercel AI SDK
Stream AI responses directly to React components with Server Actions.
1import { streamText } from 'ai';2import { openai } from '@ai-sdk/openai';34export async function POST(req: Request) {5 const { messages } = await req.json();67 const result = streamText({8 model: openai('gpt-4'),9 messages,10 });1112 return result.toDataStreamResponse();13}
Next.js + Supabase Auth
Server-side authentication with Supabase cookies and middleware.
1import { createServerClient } from '@supabase/ssr';2import { cookies } from 'next/headers';34export async function getUser() {5 const cookieStore = await cookies();67 const supabase = createServerClient(8 process.env.NEXT_PUBLIC_SUPABASE_URL!,9 process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,10 {11 cookies: {12 getAll() {13 return cookieStore.getAll();14 },15 },16 }17 );1819 const { data: { user } } = await supabase.auth.getUser();20 return user;21}
What Breaks in Production
Real issues we've encountered and how to fix them.
Symptom: Build succeeds locally, fails in production with "process.env.X is undefined"
Cause: Environment variables not prefixed with NEXT_PUBLIC_ are only available server-side
Fix: Use NEXT_PUBLIC_ prefix for client-side variables, or access them only in Server Components/API routes
// ❌ Wrong - undefined on client
const apiKey = process.env.API_KEY;
// ✅ Right - available on client
const publicKey = process.env.NEXT_PUBLIC_API_KEY;
// ✅ Right - server-side only
export async function getServerSideProps() {
const apiKey = process.env.API_KEY; // Works in server context
// ...
}
Symptom: Console warning "Text content does not match server-rendered HTML"
Cause: Client state (localStorage, Date.now()) differs from server render
Fix: Use suppressHydrationWarning or useState with useEffect
// ✅ Right - prevents hydration mismatch
'use client';
import { useState, useEffect } from 'react';
export function ClientTime() {
const [time, setTime] = useState<string | null>(null);
useEffect(() => {
setTime(new Date().toLocaleTimeString());
}, []);
return <div>{time ?? 'Loading...'}</div>;
}