| description | Use these rules when building Next.js projects |
|---|---|
| globs | src/**/*.{ts,tsx}, next.config.ts |
| alwaysApply | false |
blefnk/rules 1.0.0
- For building Next.js v15 (App Router) projects
- Guides server vs. client component usage
- React 19 is required for Next.js 15.
- Default
layout.tsxandpage.tsxto server components. Place client components into them. - Use client components for local state or interactivity.
- Use
<Link>instead for navigation unlessuseRouteris essential;<a>is disallowed. - Provide
loading.tsxand e.g.<Suspense fallback={<Skeleton />}>for asynchronous data fetching. Use Shadcn UISkeletonfor loading states. - Prefer server actions instead of client API calls.
- Maintain Edge Runtime middleware.ts compatibility (no Node.js APIs).
- Do not pass server-only event handlers or data to client components.
useFormStatereplaced byuseActionState.- Imports:
ImageResponsemoved fromnext/servertonext/og. - Async APIs:
cookies,headers,draftMode, andparamsreturn Promises—useawaitoruse(). - Caching: Fetch requests aren’t cached by default; set
cache: "force-cache"if needed. - Geo/IP: Removed from
NextRequest; use@vercel/functionsforipAddressorgeolocation. - Route Handlers: No caching unless explicitly set (
dynamic = "force-static").
{data}
;
}
"use client";
export default async function Page() {
const data = await getData();
return {data}
;
}