,
ssr: false, // Disable SSR for this component
});
```
**Image Optimization**:
```typescript
import Image from 'next/image';
export function Hero() {
return (
);
}
```
**Font Optimization**:
```typescript
import { Inter, Roboto_Mono } from 'next/font/google';
const inter = Inter({ subsets: ['latin'], variable: '--font-inter' });
const robotoMono = Roboto_Mono({ subsets: ['latin'], variable: '--font-mono' });
// In layout
```
### 9. Data Fetching Patterns
**Server Actions** (experimental):
```typescript
'use server';
export async function createPost(formData: FormData) {
const title = formData.get('title');
// Database operation
await db.post.create({ data: { title } });
revalidatePath('/posts');
redirect('/posts');
}
```
**Streaming with Suspense**:
```typescript
import { Suspense } from 'react';
export default function Page() {
return (
Dashboard
}>
);
}
```
### 10. Essential Dependencies
```json
{
"dependencies": {
"next": "^14.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "^20.0.0",
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.0",
"typescript": "^5.3.0",
"eslint": "^8.0.0",
"eslint-config-next": "^14.0.0"
}
}
```
### 11. Deployment Configuration
**Vercel** (recommended):
- Automatic deployments from Git
- Edge Functions support
- Image Optimization CDN
- Analytics built-in
**Docker** (self-hosted):
```dockerfile
FROM node:20-alpine AS base
FROM base AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
EXPOSE 3000
CMD ["node", "server.js"]
```
## Workflow
1. Ask about project requirements (API routes, auth, database, etc.)
2. Generate complete App Router structure
3. Set up metadata and SEO configuration
4. Configure middleware if needed
5. Create route groups for organization
6. Set up environment variables
7. Configure next.config.js
8. Provide setup and deployment instructions
## Example Usage
**User**: "Set up Next.js 14 with App Router and authentication"
**Response**:
Creates complete Next.js setup with:
- App Router structure with route groups
- Middleware for auth protection
- API routes for authentication
- Server and Client Components
- Metadata configuration
- Security headers
- Deployment configuration
## When to Use
- Starting new Next.js projects
- Migrating from Pages Router to App Router
- Setting up authentication flows
- Configuring SEO and metadata
- Optimizing performance
- Setting up API routes
Build production-ready Next.js applications with modern best practices!