The React Framework for production-grade applications with server-side rendering, static site generation, and full-stack capabilities
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
File conventions for App Router and Pages Router.
export default function Layout({ children }) {
return (
<div>
<nav>Navigation</nav>
<main>{children}</main>
</div>
);
}export default async function Page({ params, searchParams }) {
const data = await fetchData();
return <div>{data}</div>;
}export default function Loading() {
return <div>Loading...</div>;
}'use client';
export default function Error({ error, reset }) {
return (
<div>
<h2>Error: {error.message}</h2>
<button onClick={reset}>Try again</button>
</div>
);
}export default function NotFound() {
return (
<div>
<h2>Not Found</h2>
<Link href="/">Go Home</Link>
</div>
);
}import { NextRequest, NextResponse } from 'next/server';
export async function GET(request: NextRequest) {
return NextResponse.json({ data: 'value' });
}import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
export function middleware(request: NextRequest) {
if (request.nextUrl.pathname.startsWith('/dashboard')) {
return NextResponse.redirect(new URL('/login', request.url));
}
}
export const config = {
matcher: ['/dashboard/:path*'],
};export default function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />;
}import { Html, Head, Main, NextScript } from 'next/document';
export default function Document() {
return (
<Html>
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
);
}export default function Custom404() {
return <h1>404 - Page Not Found</h1>;
}