Dmytro Morar
Next.js

Routing

App Router maps folders in app/ to URL segments and builds a layout tree.

Route segments

  • app/dashboard/dashboard
  • app/blog/[slug]/blog/:slug
  • Each segment can include page.js, layout.js, loading.js, error.js, not-found.js.

Nested layouts

  • app/layout.jsapp/dashboard/layout.jsapp/dashboard/settings/layout.js.
  • Layouts persist across transitions and preserve state.
  • Good for shared UI: headers, sidebars, breadcrumbs.

Dynamic and catch-all routes

  • [id] or [slug] for dynamic params.
  • [...slug] for any depth.
  • [[...slug]] also matches the root.

Special routing features

  • Parallel segments (@modal, @feed) render in parallel.
  • Intercepting routes ((.), (..), (...)) enable modal routes.
  • Route Handlers (route.js) provide API endpoints.

On this page