OpenAINext.jsMay 23, 2022, 8:30 PM

Layouts RFC

A condensed section focused on the key takeaways first.

Original Post

Quick Digest

Summary

A condensed section focused on the key takeaways first.

openaienmodel: gpt-5-mini-2025-08-07

Layouts RFC — nested layouts, app directory, and server components

Key Points

  • Nested, stateful layouts via layout.js
  • app/ uses Server Components by default
  • Advanced routing: parallel, intercepting, route groups

Summary

This RFC describes the new Next.js app directory and a layout-first routing model to enable nested, stateful layouts and improved routing. Key changes include a new app/ directory (coexisting with pages/), file conventions (layout.js, page.js, loading.js), Server Components by default in app/, data fetching in layouts to avoid waterfalls, and advanced routing patterns (route groups, parallel and intercepting routes). The new router leverages React 18 features (Streaming, Suspense, Transitions) and is 100% incrementally adoptable with no breaking changes.

Key Points

  • app/ directory: opt-in alongside pages/ so you can migrate incrementally.
  • File conventions: layout.js for shared UI, page.js for route-specific UI, loading.js for loading states.
  • Root vs regular layouts: app/layout.js becomes the global root layout (replaces _app/_document); per-folder layout.js scopes layouts to subtrees.
  • Nested layouts: layouts preserve React state across sibling navigations and compose naturally in a layout tree.
  • React Server Components: files in app/ are rendered as Server Components by default; use .server.js and .client.js file suffixes to opt explicit types; plain .js files are shared.
  • Data fetching: you can fetch data inside layouts to avoid waterfalls and enable subtree-level loading and streaming.
  • Routing features: server-centric routing with SPA-like behavior, route groups, parallel routes, intercepting routes, and templates for advanced patterns.
  • Platform: router built on React 18 primitives (Streaming, Suspense, Transitions) to power streaming, instant loading states, and improved error handling.
  • Adoption: designed to be 100% incrementally adoptable with no breaking changes; feedback requested via GitHub Discussions.

Full Translation

Translations

A translation section that keeps the flow of the original article.

openaijamodel: gpt-5-mini-2025-08-07

レイアウト RFC

概要

ネストされたルートとレイアウト、クライアントおよびサーバーのルーティング、React 18 の機能を活用し、Server Components を想定して設計されたレイアウトに関する RFC。

主なポイント

  • ネストされたルートとレイアウト (Nested routes and layouts)
  • クライアントおよびサーバーのルーティングのサポート
  • React 18 の機能との互換性
  • Server Components 向けに設計

目的

  • 柔軟で再利用可能なレイアウト構造を提供すること
  • クライアントとサーバーの両方でルーティングを統一して扱えるようにすること
  • React 18 の新機能および Server Components の利点を最大限に活かすこと