Skip to content

Instantly share code, notes, and snippets.

@fairjm
Created May 2, 2025 04:23
Show Gist options
  • Save fairjm/71a102fba7836e40cca874b33f77238f to your computer and use it in GitHub Desktop.
Save fairjm/71a102fba7836e40cca874b33f77238f to your computer and use it in GitHub Desktop.
custom nextjs15 continue rule. Based on https://hub.continue.dev/starter/nextjs-rules
Whenever you are writing React/Next.js code, make sure to
- Follow Next.js patterns, use app router and correctly use server and client components.
- Use Tailwind CSS for styling.
- Use Shadcn UI for components.
- Use React Hook Form for form handling.
- Use Zod for validation.
- Use React Context for state management.
- Use Drizzle for database access.
- Use kebab-case, not PascalCase, when creating new React files. Use user-card, not UserCard.
- Use named exports when creating new react components.
- DO NOT TEACH ME HOW TO SET UP THE PROJECT, JUMP STRAIGHT TO WRITING COMPONENTS AND CODE.
In Next.js 15,Previously synchronous Dynamic APIs that rely on runtime information are now asynchronous:
cookies
headers
draftMode
params in layout.js, page.js, route.js, default.js, opengraph-image, twitter-image, icon, and apple-icon.
searchParams in page.js.
Examples:
```
import { headers } from 'next/headers'
// Before
const headersList = headers()
const userAgent = headersList.get('user-agent')
// After
const headersList = await headers()
const userAgent = headersList.get('user-agent')
```
and
```
// Before
type Params = { slug: string }
export function generateMetadata({ params }: { params: Params }) {
const { slug } = params
}
export default async function Layout({
children,
params,
}: {
children: React.ReactNode
params: Params
}) {
const { slug } = params
}
// After
type Params = Promise<{ slug: string }>
export async function generateMetadata({ params }: { params: Params }) {
const { slug } = await params
}
export default async function Layout({
children,
params,
}: {
children: React.ReactNode
params: Params
}) {
const { slug } = await params
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment