new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Next.js App Router · all subjects

app router fundamentals

5 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Script component migration to App Router

When migrating Script components to the App Router: move any 'beforeInteractive' scripts from _document.js to the root layout file (app/layout.tsx). The experimental 'worker' strategy does not work in app and scripts using it must be removed or modified to use a different strategy like 'lazyOnload'. The onLoad, onReady, and onError handlers will not work in Server Components, so move them to a Client Component or remove them.

Root layout requirements in App Router

The app directory must include a root layout. The root layout must define <html> and <body> tags since Next.js does not automatically create them. The root layout replaces pages/_app.tsx and pages/_document.tsx files. File extensions can be .js, .jsx, or .tsx.

Route Handlers replace API Routes in App Router

API Routes in pages/api continue to work without changes, but they are replaced by Route Handlers in the app directory. Route Handlers allow you to create custom request handlers using Web Request and Response APIs. Example: export async function GET(request: Request) {}

File colocating in app directory

You can colocate other files inside the app directory such as components, styles, tests, and more alongside the special files.

Nested routes and layouts in App Router

The app directory supports nested routes and layouts. Use nested folders to define routes and a special page.js file to make a route segment publicly accessible.

Give your agent this brain