forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs: Update parallel routes docs, add
default.js
pt 1. (vercel#60806)
- Loading branch information
1 parent
1cafe94
commit cb42417
Showing
3 changed files
with
79 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 27 additions & 1 deletion
28
docs/02-app/02-api-reference/02-file-conventions/default.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,32 @@ | ||
--- | ||
title: default.js | ||
description: API Reference for the default.js file. | ||
related: | ||
title: Learn more about Parallel Routes | ||
links: | ||
- app/building-your-application/routing/parallel-routes | ||
--- | ||
|
||
This documentation is still being written. Please check back later. | ||
The `default.js` file is used to render a fallback within [Parallel Routes](/docs/app/building-your-application/routing/parallel-routes) when Next.js cannot recover a [slot's](/docs/app/building-your-application/routing/parallel-routes#slots) active state after a full-page load. | ||
|
||
During [soft navigation](/docs/app/building-your-application/routing/linking-and-navigating#5-soft-navigation), Next.js keeps track of the active _state_ (subpage) for each slot. However, for hard navigations (full-page load), Next.js cannot recover the active state. In this case, a `default.js` file can be rendered for subpages that don't match the current URL. | ||
|
||
Consider the following folder structure. The `@team` slot has a `settings` page, but `@analytics` does not. | ||
|
||
<Image | ||
alt="Parallel Routes unmatched routes" | ||
srcLight="/docs/light/parallel-routes-unmatched-routes.png" | ||
srcDark="/docs/dark/parallel-routes-unmatched-routes.png" | ||
width="1600" | ||
height="930" | ||
/> | ||
|
||
When navigating to `/dashboard/settings`, the `@team` slot will render the `settings` page while maintaining the currently active page for the `@analytics` slot. | ||
|
||
On refresh, Next.js will render a `default.js` for `@analytics`. If `default.js` doesn't exist, a `404` is rendered instead. | ||
|
||
Additionally, since `children` is an implicit slot, you also need to create a `default.js` file to render a fallback for `children` when Next.js cannot recover the active state of the parent page. | ||
|
||
## Props | ||
|
||
`default.js` does not receive any props. |