惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
有赞技术团队
有赞技术团队
WordPress大学
WordPress大学
月光博客
月光博客
T
Tailwind CSS Blog
阮一峰的网络日志
阮一峰的网络日志
小众软件
小众软件
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Last Week in AI
Last Week in AI
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
罗磊的独立博客
Jina AI
Jina AI
酷 壳 – CoolShell
酷 壳 – CoolShell
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 三生石上(FineUI控件)
量子位
雷峰网
雷峰网
Apple Machine Learning Research
Apple Machine Learning Research
美团技术团队
博客园 - 聂微东
V
V2EX

tanscp

科学驾驭你的身体电量 (Body Battery) - tanscp Code Block Features Showcase 通俗易懂的解释什么是Agent - tanscp i18n in a Static Next.js Blog: Client-Side Toggle vs URL-Based Routing Multimedia Showcase: Video, Podcasts & Embeds Syntax Highlighting Mathematical Notation Visuals and Diagrams System Architecture 101 Syntax Highlighting Showcase 中文测试文章 Part 1: Getting Started with Next.js 15 多语言测试并且要测试以下超长的标题看如何处理,如果太长的话要考虑方案: Amytis Digital Garden The Kitchen Sink: Comprehensive Feature Test Mac 菜单栏武装计划:10 款免费开源的宝藏 App 推荐 Markdown Features Test Nested Image Test Legacy Markdown Support Asynchronous JavaScript QuickSort: An Algorithmic Deep Dive README Index Post Deeper Notes 在一个被屏幕和算法全面包围的时代,我们正逐渐失去对“注意力”的主权 - tanscp AI 是如何识别一只猫的?——图解神经网络的秘密 - tanscp 什么是真正的自我?它真的存在吗? - tanscp AI洞察从你的笔记中读出了什么? - tanscp 我尝试空腹有氧一个月后 - tanscp ISSUE 026 | 数独事件 - tanscp ISSUE 025|你喜欢哪个版本的自己? - tanscp ISSUE 024|认知失调 - tanscp
Part 2: Routing Mastery
John Hu · 2026-01-31 · via tanscp

In Next.js 15, folders are routes and files are pages. This convention-based approach eliminates the need for a separate routing configuration — your project structure is your route map.

Routing Diagram

File-Based Routing

Every folder inside app/ becomes a URL segment. A page.tsx file inside that folder makes it publicly accessible:

Dynamic Routes

Square brackets denote dynamic segments. The parameter value is passed to your component:

The generateStaticParams function tells Next.js which pages to pre-render at build time, enabling fully static output.

Layouts

Layouts wrap pages and persist across navigation. They're defined with layout.tsx and receive children as a prop:

Nested layouts compose naturally. A posts/layout.tsx wraps all post pages without affecting the rest of the site.

Parallel Routes

Parallel routes let you render multiple pages in the same layout simultaneously, using named slots:

The layout receives each slot as a prop:

Intercepted Routes

Intercepted routes display a route within the context of another route — perfect for modals. The (.) convention intercepts a sibling route:

When a user clicks a post link from the listing page, the intercepted route renders as a modal. If they navigate directly to the URL or refresh, they see the full page.

m-p-model M-P-Model

Summary

Next.js routing is built on a few simple conventions that scale from a single-page site to a complex application. The file system does the heavy lifting — no router configuration, no route registration, just folders and files.