This removes the `--turbopack` and `--turbo` flags from `next start`, as
it correctly launches the server to handle Turbopack builds without the
flag.
It also removes this section from the documentation.
This is a breaking change, but Turbopack-powered builds are
experimental, so this can probably go out with the next stable release.
### What?
Updates the `userAgent` middleware example in the documentation to
accurately reflect all possible values of `device.type` and demonstrate
proper handling of desktop browsers (undefined case).
### Why?
The current example shows a binary mobile/desktop check which doesn't
accurately reflect the API's capabilities. The `device.type` property
can actually return multiple values ('mobile', 'tablet', 'console',
'smarttv', 'wearable', 'embedded', or undefined), but the example only
shows handling of 'mobile', which could mislead developers.
### How?
- Updated both TypeScript and JavaScript examples to:
1. Add comprehensive comments documenting all possible `device.type`
values
2. Use proper undefined handling with the OR operator for desktop
browsers
3. Maintain consistency between TS and JS versions
4. Better align with the documented behavior in the API reference
- Ran `pnpm prettier-fix` to ensure proper formatting
- Followed the [Docs Contribution
Guide](https://nextjs.org/docs/community/contribution-guide)
The changes help developers better understand:
- The full range of device types they can detect
- How desktop browsers return undefined
- The proper way to handle device type detection
- Consistency with the rest of the API documentation
### Checklist
- [x] Read the [Docs Contribution
Guide](https://nextjs.org/docs/community/contribution-guide)
- [x] Ran `pnpm prettier-fix` to fix formatting issues
- [x] Ensured examples are clear and follow documentation best practices
- [x] Maintained consistency with existing documentation style
- [x] Verified the accuracy of the technical information
---------
Co-authored-by: JJ Kasper <jj@jjsweb.site>
### What?
Clarified the description of the NextRequest object in the route handler
documentation. Specifically, I reworded the sentence to improve
readability.
Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
<!--
Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible, please follow
the checklist sections below.
Choose the right checklist for the change(s) you're making:
-->
## For Contributors
### Improving Documentation
- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the [Docs Contribution
Guide](https://nextjs.org/docs/community/contribution-guide) to ensure
your contribution follows the docs guidelines.
### Adding or Updating Examples
- Follow the [examples contribution
guidelines](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md).
- Ensure linting passes by running `pnpm build && pnpm lint`.
See: [Linting
Docs](https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md)
### Fixing a Bug
- Link-related issues using `fixes #number`.
- Add relevant tests. See: [Testing
Guide](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Ensure errors include helpful links.
Reference: [Error Links
Guide](https://github.com/vercel/next.js/blob/canary/contributing.md)
### Adding a Feature
- Implements an accepted feature request or RFC.
(Ensure there's an approved discussion: [Submit
Idea](https://github.com/vercel/next.js/discussions/new?category=ideas))
- Link issues or discussions using `fixes #number`.
- Add e2e tests where appropriate.
See: [e2e Testing
Guide](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Include updated documentation.
- Add telemetry (if needed) to determine usage.
- Ensure errors have helpful links attached.
---
## For Maintainers
- Provide a minimal, clear description (as if explaining to someone
unfamiliar with the context).
- Share Slack thread summaries when referencing discussions.
- Link both Linear (`Fixes NEXT-xxx`) and GitHub issues.
- Leave review comments where the logic behind changes might not be
obvious.
---
### What?
Updated documentation and installation instructions to include
`@types/jest`.
### Why?
When setting up Jest in a TypeScript project, omitting `@types/jest`
causes TypeScript to fall back to `node:test`, leading to incorrect
module resolution and runtime errors. Including `@types/jest` resolves
this and ensures a smooth development experience.
### How?
Added `@types/jest` to the recommended install commands wherever
applicable, ensuring consistent and error-free setup for users following
the docs.
Closes `NEXT-`
Fixes `#`
Explains how to run the Turbopack trace viewer. This tool is focused on
low-level observability. We use it to optimize Turbopack performance and
memory usage. It's also useful for finding slowdowns caused by
customization like postcss / custom loaders and such.
<!-- 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
### Adding or Updating Examples
- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md
### 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
## 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 #
-->
Closes: https://linear.app/vercel/issue/DOC-4498/clean-up-appdocs
- Went through the FAQ on the page and made sure the information is
found in other places in our docs.
- With the IA changes, we shouldn't need a FAQ that duplicates
information.
- We can have a dedicated App Router FAQ page in the future - if there's
a need for it.
Decoupling from: https://github.com/vercel/next.js/pull/73437
- Add "How `use cache` works" section
- Clarify cache keys inputs
- Describe what happens during build, runtime, and revalidation
- Correct the default values for the `cacheLife` profiles
- Add the default time for `expireTime`
- Add note about `staleTimes` and `expireTime` affecting the default
cache profile
Turbopack: update docs for `config.turbopack`
As `turbo.mdx` is renamed to `turbopack.mdx`, we’ll need a redirect on
the nextjs.org website to take users to the new location. This will be a
separate PR in its repository.
---------
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
The file tree can be improved and share the same convention:
- Use the `txt` file extension.
- One tab indented.
- Use file tree with root `.` and trailing slash for folders.
x-ref: https://tree.nathanfriend.io
Closes PACK-4263
This:
- Adds support for using `config.turbopack` for Turbopack. The accepted value for this option is identical to the previous experimental one without the deprecated field `loaders`.
- Deprecates `config.experimental.turbo`. Warns on its use, but will continue to accept it, merging it with `config.turbopack` while preferring fields on `config.turbopack`.
- also see https://github.com/vercel/next.js/pull/77850#pullrequestreview-2749738760
Test Plan:
- [x] Convert use of `config.experimental.turbo` in tests to `config.turbopack`
- [x] Automated test for accepting the experimental option for compatibility, as well as the config merging
This section will be for developers who want to understand how things
work. It's not essential knowledge, but good to know.
A place for conceptual information and colorful diagrams that explain
the magic behind things ✨🌈
Configuring `remotePatterns` can be a hassle because you have to define
each of the parts. And if you forget a part, its a wildcard meaning it
will match anything. This is usually not desirable since most remote
images don't allow query strings.
This PR adds support for using an array of `URL` objects when defining
`images.remotePatterns`.
```js
module.exports = {
images: {
remotePatterns: [
new URL('https://res.cloudinary.com/my-account/**'),
new URL('https://s3.my-account.*.amazonaws.com/**'),
],
},
}
```
Note that wildcards must be explicit and anything missing is assumed to
no longer match.