Files
vercel__next.js/errors/slot-missing-default.mdx
Hojeong Park 64429129c0 docs: fix typo in slot-missing-default.mdx (#94531)
Fixed a typo in `errors/slot-missing-default.mdx`:

- `Optiona` → `Optional`

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Signed commits

- This repository requires verified commit signatures on protected
branches.
- If this pull request is blocked for unsigned commits, re-sign the
commits and force-push the branch.
- A `Signed-off-by` line in the commit message is not enough.


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
2026-06-22 14:37:30 +02:00

81 lines
2.7 KiB
Plaintext

---
title: Missing Required default.js for Parallel Route
---
> Parallel route slots require a `default.js` file to serve as a fallback during navigation.
## Why This Error Occurred
You're using [parallel routes](https://nextjs.org/docs/app/api-reference/file-conventions/parallel-routes#defaultjs) in your Next.js application, but one of your parallel route slots is missing a required `default.js` file, which causes a build error.
When using parallel routes, Next.js needs to know what to render in each slot when:
- Navigating between pages that have different slot structures
- A slot doesn't match the current navigation (only during hard navigation)
- After a page refresh when Next.js cannot determine the active state for a slot
The `default.js` file serves as a fallback to render when Next.js cannot determine the active state of a slot based on the current URL. Without this file, the build will fail.
## Possible Ways to Fix It
Create a `default.js` (or `.jsx`, `.tsx`) file in the parallel route slot directory that's mentioned in the error message.
For example, if you have this structure where different slots have pages at different paths:
```
app/
├── layout.js
├── page.js
├── @team/
│ └── settings/
│ └── page.js
└── @analytics/
└── page.js
```
You need to add `default.js` files for each slot, excluding the children slot:
```
app/
├── layout.js
├── page.js
├── default.js // Optional: add this (for children slot)
├── @team/
│ ├── default.js // Add this
│ └── settings/
│ └── page.js
└── @analytics/
├── default.js // Add this
└── page.js
```
Without the root `default.js`, navigating to `/settings` would result in a 404, even though `@team/settings/page.js` exists. The `default.js` in the root tells Next.js what to render in the children slot when there's no matching page at that path. It's not required as other named slots default files are, but it's good to add to help improve the experience for your applications.
### Example `default.js` file:
The simplest implementation returns `null` to render nothing:
```jsx filename="app/@analytics/default.js"
export default function Default() {
return null
}
```
You can also preserve the old behavior of returning a 404:
```jsx filename="app/@team/default.js"
import { notFound } from 'next/navigation'
export default function Default() {
notFound()
}
```
### When you need `default.js`
You need a `default.js` file for each parallel route slot (directories starting with `@`) at each route segment.
## Useful Links
- [Parallel Routes Documentation](https://nextjs.org/docs/app/api-reference/file-conventions/parallel-routes#defaultjs)