3446 Commits

Author SHA1 Message Date
Kowyo 5a22623262 example: remove duplicate items in .dockerignore (#91079)
Removed duplicate entries for cache and temporary directories.

```diff
- # Cache directories and temporary data
- .cache/
- .parcel-cache/
- .eslintcache
- .stylelintcache
- .turbo/
- .tmp/
# Cache directories and temporary data
.cache/
.parcel-cache/
.eslintcache
.stylelintcache
.swc/
.turbo/
.tmp/
.temp/
```

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-03-09 13:21:27 +01:00
Karl Horky a0d293fc08 with-docker: add new config file formats (#90731)
<!-- 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


## 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 #

-->

### What?

Update config files in the `with-docker` example inside the
`.dockerignore`

### Why?

They are outdated

### How?

Add lines

cc @icyJoseph

---------

Co-authored-by: Joseph <sephxd1234@gmail.com>
2026-03-02 11:39:03 +01:00
Joseph 7643fc9483 example: restore .next handling for with-docker examples (#90651)
- Remove BuildKit cache mount on `.next/cache` that trapped fetch cache
in a volume unreachable by the runner stage
- Restore `mkdir .next && chown` in runner stage for writable prerender
cache
- Add commented-out `COPY .next/cache` line as opt-in for persisting
build-time fetch cache
- Apply same fixes to `Dockerfile.bun` (only needed the `mkdir`/`chown`,
it never had the BuildKit mount)

Closes #90648
2026-02-27 15:23:45 +01:00
Hayden Bleasel 22e46a40ad Migrate from react-markdown to Streamdown static in EdgeDB example (#86435)
This pull request updates the blog post rendering in the EdgeDB example
to use our `streamdown` library in static mode instead of
`react-markdown` for Markdown parsing and rendering.

---------

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-02-21 00:39:53 +01:00
Kristiyan Velkov d7732c57d6 [feat] Added Docker examples for standalone output and export output following best practices (#87069)
## What?

Modernizes the existing `with-docker` example and adds a new
`with-docker-export-output` example demonstrating different Next.js
deployment strategies with Docker best practices:

1. **`with-docker` (updated)** - Modernized to use App Router,
TypeScript, Tailwind CSS v4, and comprehensive Docker best practices.
Now includes both Node.js and Bun Dockerfile options, Docker Compose
with profiles, BuildKit cache mounts, and extensive documentation.

2. **`with-docker-export-output` (new)** - Demonstrates Next.js static
export mode deployment with Docker, offering two serving options:
**Nginx** (production-grade) and **serve** package (Node.js-based,
simpler setup). Includes optimized Nginx configuration, BuildKit cache
mounts, and comprehensive documentation.

Both examples include detailed documentation explaining Docker best
practices, implementation decisions, and deployment guidance.

## Why?

The existing `with-docker` example was using the Pages Router and
lacked:

- Modern Next.js patterns (App Router, TypeScript)
- Detailed documentation explaining Docker best practices and
implementation decisions
- BuildKit cache mounts for optimized build performance
- Bun runtime support as an alternative to Node.js
- Docker Compose configurations for easier local development
- Clear documentation about Node.js image variant choices (slim vs
Alpine)
- Examples demonstrating static export mode

These updates serve as comprehensive references for developers who want
to understand:

- How to Dockerize Next.js applications for different deployment
scenarios
- Why certain choices are made and how to optimize Docker setups for
production
- When to use standalone mode vs static export mode
- How to choose between Node.js and Bun runtimes
- How to choose between different web servers (Nginx vs serve) for
static sites

## How?

### `with-docker` example (updated)

- **Migrated to App Router** with TypeScript and Tailwind CSS v4
- **Multi-stage Dockerfile** with three stages: dependencies
installation, build, and runtime
- **Bun support** via `Dockerfile.bun` with optimized configuration
- **BuildKit cache mounts** for package manager stores (`npm`, `yarn`,
`pnpm`, `bun`) and Next.js build cache
- **Security best practices** with non-root user execution (built-in
`node` and `bun` users)
- **Docker Compose configuration** with profiles for Node.js (default)
and Bun
- **Comprehensive `.dockerignore`** to minimize build context size
- **Detailed README** explaining standalone mode benefits, Node.js image
choices, and deployment guidance
- **Deleted** `with-docker-standalone-output` (merged into this example)

### `with-docker-export-output` example (new)

- **Two Dockerfile options:**
- `Dockerfile` - Nginx-based serving with `nginxinc/nginx-unprivileged`
for security
- `Dockerfile.serve` - Node.js serve package-based serving for simpler
deployments
- **Multi-stage builds** for both options with separate dependency,
build, and runtime stages
- **BuildKit cache mounts** for package manager stores and Next.js build
cache
- **Production Nginx configuration** (`nginx.conf`) with gzip
compression, caching headers, and security best practices
- **Docker Compose configuration** supporting both serving options via
profiles
- **Comprehensive README** explaining static export mode, trade-offs
between Nginx and serve

### Docker best practices implemented (both examples)

| Practice | Description |
|----------|-------------|
| Multi-stage builds | Optimal image size reduction |
| Layer caching | Package files copied first |
| Minimal build context | Comprehensive `.dockerignore` files |
| BuildKit cache mounts | Faster subsequent builds |
| Security hardening | Non-root user execution |
| Corepack | yarn/pnpm version management |
| Package manager auto-detection | npm, yarn, pnpm support |
| Node.js 24.13.0-slim | Clear upgrade guidance |

## Breaking Changes

> **Warning**
> - `with-docker` now uses App Router instead of Pages Router
> - `with-docker-standalone-output` has been removed (merged into
`with-docker`)

---

**Note:** After this PR is approved and merged, I plan to open a
follow-up PR to update the Next.js documentation with proper links to
these Docker examples.

---------

Co-authored-by: Wyatt Johnson <accounts+github@wyattjoh.ca>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
Co-authored-by: kristiyan.velkov <kristiyan.velkov@ffw.com>
2026-02-20 15:57:11 +01:00
Joseph d6d84be211 Remove more examples (#89709)
Removing examples that we are not using, or maintaining anymore.
2026-02-09 10:36:57 +00:00
Jam Balaya 1ac8cb06e3 chore(examples): remove with-tigris example (#81843)
## Summary

Remove the
[with-tigris](https://github.com/vercel/next.js/tree/canary/examples/with-tigris)
example and clean up its references in lint and test configs

Build:
- Remove with-tigris paths from .eslintignore
- Remove with-tigris entry from turbopack-dev-examples-manifest.json

Chores:
- Delete the with-tigris example directory and all its files

## Why?


[@tigrisdata/core](https://github.com/tigrisdata-archive/tigris-client-ts)
package hasn't been maintained in 2 years.

## Adding or Updating Examples

- [x] The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- [x] Make sure the linting passes by running `pnpm build && pnpm lint`.
See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

cc: @samcx

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-02-04 16:44:11 +01:00
Jam Balaya c2214e7aae chore(examples): remove with-recoil exmaple (#81836)
## Summary

Remove the deprecated
[with-recoil](https://github.com/vercel/next.js/tree/canary/examples/with-recoil)
example and update the examples manifest accordingly

Chores:
- Delete the examples/with-recoil directory and its contents
- Remove the with-recoil entry from
test/turbopack-dev-examples-manifest.json

## Why?

[Recoil](https://github.com/facebookexperimental/Recoil) was archived by
the owner on Jan 2, 2025.

## Adding or Updating Examples

- [x] The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- [x] Make sure the linting passes by running `pnpm build && pnpm lint`.
See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

cc: @samcx

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-02-03 21:45:37 +01:00
Sebastian "Sebbie" Silbermann a04499797e Re-enable types-and-precompiled (#89070) 2026-01-26 23:19:43 +00:00
Simeon Griggs 70d357a3ea Update with-mysql example to Next.js 15, Tailwind 4, Prisma 7 (#88475)
## Summary

Updates the `with-mysql` example to use latest versions of all
dependencies.

### What

- Migrate from Pages Router to App Router
- Update to React 19 and Next.js latest
- Update to Tailwind CSS v4 with `@import "tailwindcss"` syntax
- Update to Prisma 7 with `@prisma/adapter-planetscale` driver adapter
- Convert all files to TypeScript
- Remove unused API route and `vercel.svg`
- Update README to clarify this is for PlanetScale MySQL and link to
[vercel/postgres-next-starter](https://github.com/vercel/postgres-next-starter)
for Postgres users

### Why

The example was significantly outdated:
- Prisma 3.10.0 → Prisma 7 (latest)
- Tailwind 3.0.23 → Tailwind 4
- React 18.2.0 → React 19
- Pages Router → App Router

### How

Followed the official migration guides:
- [Prisma 7 upgrade
guide](https://www.prisma.io/docs/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-7)
- [PlanetScale quickstart with
Prisma](https://www.prisma.io/docs/getting-started/prisma-orm/quickstart/planetscale)
- Aligned configuration files with a fresh `create-next-app` output

## Related

N/A

## How to Test

```bash
cd examples/with-mysql
npm install
# Set up .env with your PlanetScale DATABASE_URL
npx prisma generate
npx prisma db push
npx prisma db seed
npm run dev
```

## Checklist

- [x] Tests and samples are included
- [x] Documentation is updated (README)

---------

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
2026-01-20 12:16:44 +01:00
Nhan Nguyen c68d18c507 fix(examples): resolve hydration mismatch in blog-starter (#87703)
## What?
Add `suppressHydrationWarning` to the `<html>` element in the
blog-starter example.

## Why?
The ThemeSwitcher script runs before React hydration and adds `dark`
class and `data-mode` attribute to the `<html>` element, causing a
hydration mismatch error.

## How?
Add `suppressHydrationWarning` to the `<html>` element to tell React
this mismatch is intentional.

Fixes #74586

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-12-23 21:02:35 +00:00
pji2918 2446efeaa6 fix: Change Dockerfile.bun to use group/useradd instead of addgroup/user (#87443)
<!-- 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


## 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
-->

(sorry for my bad english)

### What?
Change `/examples/with-docker/Dockerfile.bun` to use group/useradd
instead of addgroup/user.

### Why?
Currently, the `docker build` command results in an error
`/bin/sh: 1: addgroup: not found`.
(related issue: oven-sh/bun#25441)

### How?
I changed the addgroup/user command to user/groupadd as a workaround.
[#](https://github.com/oven-sh/bun/issues/25441#issuecomment-3668036074)

fixes #87722.

---------

Co-authored-by: Joseph <sephxd1234@gmail.com>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-12-23 18:34:44 +01:00
nextjs-bot 1c09f4494b Upgrade React from b45bb335-20251211 to f93b9fd4-20251217 (#87281) 2025-12-18 00:10:32 +00:00
Benjamin Woodruff ea927b583d Turbopack: Improve the description on InvalidLoaderRuleConditionIssue (#87008)
It's near-impossible to get this to error on the Rust side (issues are caught before we get here), but I hacked up the code to make it error. It looks like this:

![Screenshot 2025-12-09 at 4.39.24 PM.png](https://app.graphite.com/user-attachments/assets/796b5efa-b2e5-4a9c-bcf3-03cee0a0861d.png)
2025-12-12 12:51:14 -08:00
Sebastian "Sebbie" Silbermann 435000f407 Upgrade React from 55480b4d-20251208 to 80cb7a99-20251211 (#87078) 2025-12-11 22:05:41 +01:00
Joseph ac8d891d95 examples: ensure examples use latest versions (#86949) 2025-12-09 21:22:08 +01:00
nextjs-bot 6ef90ef49f Upgrade React from fd524fe0-20251121 to 7dc903cd-20251203 (#86771) 2025-12-03 16:20:59 +00:00
Jam Balaya 555838ecbe examples: fix typos in cms-agilitycms (#82504)
## Summary

Correct spelling errors in the cms-agilitycms example, including the
image prop spelling and dependency imports.

Bug Fixes:
- Fix misspelled intersectionTreshold prop to intersectionThreshold in
the Image component and its useInView configuration

Enhancements:
- Rename dependancies.ts to dependencies.ts and update
requireComponentDependancyByName to requireComponentDependencyByName
across API and component imports

### Adding or Updating Examples

- [x] The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- [x] Make sure the linting passes by running `pnpm build && pnpm lint`.
See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-11-26 00:05:18 +01:00
Jam Balaya 0dd4ba3fd6 chore(examples): remove with-windicss example (#81846)
## Summary

Delete the entire
[with-windicss](https://github.com/vercel/next.js/tree/canary/examples/with-windicss)
directory and its contents

## Why?

[windicss](https://github.com/windicss/windicss) is
[sunsetting](https://windicss.org/posts/sunsetting.html).

## Adding or Updating Examples

- [x] The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- [x] Make sure the linting passes by running `pnpm build && pnpm lint`.
See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

cc: @samcx

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-11-25 10:01:41 +01:00
Jam Balaya d45fc5ad95 examples: fix typos (#82506)
## Summary

Fix typos in code, styles, and documentation across multiple example
projects

Chores:
- Correct variable name typo in the with-slate example
(edtorState→editorState)
- Fix CSS/SASS class name misspellings (populer→popular, Serach→Search,
serachSelector→searchSelector)
- Update example documentation and comments to fix English typos (Data
SOUCE→SOURCE, accessiblity→accessibility, exchanges, doesn't, deploying,
validates, quickly)

### Adding or Updating Examples

- [x] The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- [x] Make sure the linting passes by running `pnpm build && pnpm lint`.
See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-11-24 14:04:41 +01:00
Jon Meyers fc4f062ba9 Chore: Update with-supabase example to Next.js 16 (#86105)
### What?

Upgrade with-supabase example to be compatible with Next.js 16

### Why?

1. Users get console warnings about middleware vs proxy
2. Enabling Cache Components config results in build errors for async
behaviour outside Suspense boundary
3. Turbopack flag is default and therefore, no longer necessary on `npm
run dev`

### How?

1. Renamed all instances of `middleware` to `proxy`
2. Wraped async behaviour in Suspense boundaries
3. Removed --turbopack flag from `npm run dev`

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2025-11-17 22:41:21 -08:00
Jiwon Choi 61136d8e4b [devtools] Remove title from preferences (#85698)
The heading sections in DevTools regressed. We decided to remove them as
"Dev Server" settings are obviously dev server settings, no need to
differentiate as separate tabs.

| Before | After |
|--------|--------|
| <img width="1024" height="1006" alt="CleanShot 2025-11-02 at 12 59
21@2x"
src="https://github.com/user-attachments/assets/0a8b0c2f-3f0a-487d-9344-b33b5ee016f5"
/> | <img width="1024" height="1006" alt="CleanShot 2025-11-02 at 12 59
07@2x"
src="https://github.com/user-attachments/assets/ddd3b029-8957-4129-aaf2-7b1a57a52e00"
/> |
2025-11-02 13:14:20 +01:00
Luke Sandberg e2262334f8 [turbopack] Implement improved deobfuscation for free calls and module identifiers. (#85060)
Improve deobfuscation of 'imported module identifier' and attempt to deobfuscate error messages logged by the server.

Before
```
 ⨯ TypeError: (0 , __TURBOPACK__imported__module__$5b$project$5d2f$examples$2f$with$2d$turbopack$2f$app$2f$foo$2e$ts__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__.foo) is not a function
    at Page (app/page.tsx:5:6)
  3 | export default function Page() {
  4 |   /** @ts-ignore */
> 5 |   foo();
    |      ^
  6 |   return <h1>Hello, Next.js!</h1>;
  7 | }
  8 | {
```
after 
```
 ⨯ TypeError: {imported module ./examples/with-turbopack/app/foo.ts}.foo is not a function
    at Page (app/page.tsx:5:6)
  3 | export default function Page() {
  4 |   /** @ts-ignore */
> 5 |   foo();
    |      ^
  6 |   return <h1>Hello, Next.js!</h1>;
  7 | }
  8 | {
```

Similarly in devtools
before:

![image.png](https://app.graphite.dev/user-attachments/assets/fd50d94a-d34a-4026-862e-0ca8ee6658ba.png)

after

![image.png](https://app.graphite.dev/user-attachments/assets/d9080ed7-29c8-428a-831a-9bbcd818cc3e.png)


This is definitely an improvement but i am not sure i put the deobfuscation logic in the best place for the console case.  Happy for feedback
2025-10-21 13:54:28 -07:00
Luke Sandberg d917d2e45f [turbopack] Prevent accidental access to .next (#84714)
Certain patterns in source code cause turbopack to scan the project directories for resources.  This can go wrong when one of those patterns can traverse into .next (oroborous!).

There is no usecase for turbopack to read files from the distDir during analysis and we can prevent that with a simple filter at the FileSystem layer which is what this PR does.  Given the recent `build/dev` split this is a little subtle, so i added a new property to `NextConfigComplete` so we always pass the original `distDir` down even when we are performing the `dev` split.

The semantics of this are implemented at the filesystem layer which means:
* writing into a 'denied_path' is an error
* reading a denied path is 'not found'
* reading the parent directory of a denied path filters it.

Closes PACK-5593
2025-10-17 16:18:16 -07:00
Carlo Quick 04c7cef99b [docs] fix(with-supabase): Update README env variables (#84745)
Closes #84734

Fixes environmental variable names in `with-supabase` example README to
match the actual `.env.example` file.

Updates `NEXT_PUBLIC_SUPABASE_ANON_KEY` to
`NEXT_PUBLIC_SUPABASE_PUBLISHABLE_OR_ANON_KEY` in two locations.

---------

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-10-13 13:07:28 +02:00
Ben Gubler 41e39426eb Remove automatic linting from build (#83136)
### What?
This PR removes the automatic ESLint linting that previously ran during `next build`. The documentation has been updated to reflect this change.

### Why?
As part of Next.js 16, we're removing the automatic build-time linting that was previously included in the build process. This gives developers more control over when linting runs by explicitly invoking their linter via npm scripts.

### How?
- Updated documentation to clarify that automatic build-time linting has been removed in Next.js 16
- Removed the `runLint` parameter and related linting code from the build process
- Removed the `verifyAndLint.ts` file which is no longer needed
- Simplified type checking code by removing lint-related functionality
- Removed ESLint telemetry during builds
2025-10-08 16:35:07 -07:00
nextjs-bot 9f98bf7705 Upgrade React from 86181134-20251001 to a757cb76-20251002 (#84463) 2025-10-02 17:18:41 +00:00
Jiwon Choi a843a49b96 examples: Remove AMP example (#84355)
Stacked on https://github.com/vercel/next.js/pull/84312

Removes the AMP example, which is no longer supported.
2025-09-30 15:22:03 +02:00
RobertFent 3f75ff69cb Use Array.from to avoid @ts-ignore when copying i18n.locales (#82148)
### What?
Replaces:
```ts
// @ts-ignore locales are readonly
const locales: string[] = i18n.locales;
```
with:
```ts
const locales = Array.from(i18n.locales);
```

### Why?
Avoids suppressing TypeScript errors via @ts-ignore.
Array.from safely creates a mutable copy without modifying the readonly
original, making the code cleaner and more type-safe.

### How?
Used Array.from(i18n.locales) instead of a forced type assertion.<br>

<br>
No functional change, purely a lint-/type-safety improvement.

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-09-30 00:13:41 +02:00
Samii2383 1d8cc7266a docs: update Dockerfile to use node:lts-alpine instead of node:18-alpine (#84229)
## Summary
Updated
`examples/with-docker-compose/next-app/prod-without-multistage.Dockerfile`
to use `node:lts-alpine` instead of `node:18-alpine`, since Node 18 is
reaching end of life and contains known vulnerabilities.

## Changes
- Updated base image in prod-without-multistage.Dockerfile from
`node:18-alpine` → `node:lts-alpine`

## How I Tested
- Built Docker image locally → worked successfully.

## Notes
Part of cleanup for outdated Docker examples.

---------

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-09-25 14:59:41 +02:00
Alexander Lichter cef3dd05aa chore: improve oxlint example (#83898)
Follow-up of https://github.com/vercel/next.js/pull/83842

This PR adds the `eslint` plugin which enforces eslint-core rules, as
well as defines `ignorePatterns` that should work well with Next.js by
default

---------

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-09-18 13:42:05 +02:00
ericx0099 bc9fe492db fix: correct typo 'incomming' to 'incoming' in with-mqtt-js example (#83887)
### What?
This PR fixes a typo in the `with-mqtt-js` example
(`examples/with-mqtt-js/app/page.tsx`):
all occurrences of "incomming" have been corrected to "incoming" in
variables, refs, and JSX headings.

### Why?
The previous spelling "incomming" is incorrect in English. Correcting it
improves readability and professionalism in the example code.

### How?
- Renamed `incommingMessages` → `incomingMessages`
- Renamed `setIncommingMessages` → `setIncomingMessages`
- Renamed `incommingMessageHandlers` → `incomingMessageHandlers`
- Updated JSX headings and references accordingly

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2025-09-17 08:38:49 -07:00
Alexander Lichter f6b98578d3 chore: add example with oxlint (#83842)
### What?

This PR adds an example on how to lint your app with Oxlint

### Why?

As an example to user another linter than Biome or ESLint.

---------

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
Co-authored-by: Joseph <sephxd1234@gmail.com>
2025-09-17 11:08:44 +02:00
Dharun R d43e5f9378 docs: Convert relative imports to @ aliases in examples (#83813)
## For Contributors

### Improving Documentation

This PR improves the Next.js examples by converting relative imports to
@ aliases, making them more readable and maintainable.

## Description

Fixes #83717 by converting deep relative imports to clean @ aliases in
Next.js examples.

Currently, Next.js examples use long relative imports like:
```typescript
import { i18n, type Locale } from "../../../i18n-config";
```
This PR updates them to use clean @ aliases:
```typescript
import { i18n, type Locale } from "@/i18n-config";
```

## Changes Made

- **Added path alias configuration** `"@/*": ["./*"]` to tsconfig.json
files
- **Converted deep relative imports** (d:) to clean @ aliases (`@/`)
- **Updated examples**:
  - `i18n-routing` (specifically mentioned in issue #83717) - 5 files
  - `with-typescript` - 2 files  
  - `with-grafbase` - 2 files
  - `with-mongodb-mongoose` - 2 files

## Benefits

-  **Improved readability**: `@/config` vs `../../../config`
-  **Reduced errors**: No need to count `../` levels when refactoring
-  **Better maintainability**: Easier to move files around
-  **Modern standards**: Aligns with production Next.js practices
-  **Better IDE support**: Enhanced autocomplete and navigation

## Examples of Changes

### Before:
```typescript
import { i18n, type Locale } from "../../../i18n-config";
import { getDictionary } from "../../get-dictionary";
import { grafbase } from "../../../lib/grafbase";
```

### After:
```typescript
import { i18n, type Locale } from "@/i18n-config";
import { getDictionary } from "@/get-dictionary";
import { grafbase } from "@/lib/grafbase";
```

## Testing

-  TypeScript compilation works correctly
-  @ imports resolve properly in IDE
-  Runtime functionality preserved
-  No breaking changes to example functionality

This change is purely a developer experience improvement and doesn't
affect runtime behavior.

---------

Co-authored-by: dharunr36 <dharunr.23aid@kongu.edu>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-09-16 15:53:53 +02:00
Tom Moses 107458887e examples(with-supabase): fix import statement in tutorial (#83605)
Fixed import statements in tutorial code to point to files in the
correct folders.

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-09-09 11:59:00 +00:00
Hamad Ullah 85a2a029bc Fix/msw-issue-68521 (#83482)
### Fix: [68521](https://github.com/vercel/next.js/issues/68521)
Updating outdated with-msw example
The
[with-msw](https://github.com/vercel/next.js/tree/canary/examples/with-msw)
is outdated and doesn't work with the latest msw version.

### What?
The
[with-msw](https://github.com/vercel/next.js/tree/canary/examples/with-msw)
example is outdated and does not work with the latest msw version.

### Why?
- msw now uses http instead of rest and the outdated implementation does
not work with the latest version anymore.
- the client-side worker is now imported through msw/browser.

### How?
- replaced all usage of rest with http to align with MSW's new API.
- updated the worker import to use msw/browser as per the new structure.

### Media

https://github.com/user-attachments/assets/ab9ebb49-28b2-4095-aeea-dcd301093c9f

---------

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-09-08 09:11:34 +02:00
Jakob Klotz f41c809353 Docker example using bun (#83040)
### What?

Expanded the `with-docker` example for usage with `bun` and added build
instructions to the README.

### Why?

The existing example supports npm, yarn and pnpm, but not bun. 

### How?

- Add a separate Dockerfile.bun placed next to the existing Dockerfile,
which is more sensible for the existing solution.
- Dockerfile.bun uses the official oven/bun base image (different
runtime/tooling than node:18-alpine), so a separate file should be
clearer.
- Existing Docker commands in the README remain unchanged, because
Docker still uses the existing Dockerfile by default.
- The bun example can be built with: `docker build -f Dockerfile.bun -t
nextjs-docker .`

Related to #78465, #82998

---------

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Co-authored-by: Joseph <sephxd1234@gmail.com>
2025-09-03 21:57:29 +00:00
Jesse Hall cce01badd8 examples(with-mongodb): upgrade to tailwind v4 (#83225)
Upgraded to tailwind 4 and updated react version and dependencies.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Jiwon Choi <devjiwonchoi@gmail.com>
Co-authored-by: Michael Arguin <michael.arguin@vercel.com>
2025-09-03 09:12:33 +02:00
JUNAID ALI KHAN c776c25b59 docs(docker): update base image to node:20-alpine in Docker examples (#83125)
This PR updates all example Dockerfiles that were using `node:18-alpine`
to `node:20-alpine`
to align with current LTS and address known issues in Node 18 images.

- examples/with-docker/Dockerfile
- examples/with-docker-compose/next-app/prod.Dockerfile
- examples/with-docker-compose/next-app/dev.Dockerfile
- examples/with-docker-multi-env/docker/development/Dockerfile
- examples/with-docker-multi-env/docker/production/Dockerfile
- examples/with-docker-multi-env/docker/staging/Dockerfile

I verified local builds for each example. No behavior changes;
docs/examples only.


https://github.com/vercel/next.js/issues/78465

---------

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-09-02 19:06:42 +02:00
Remco Haszing 7aa5d16231 Use the automatic runtime for type checking (#83159)
Co-authored-by: Sebastian "Sebbie" Silbermann <silbermann.sebastian@gmail.com>
2025-09-02 12:35:42 +02:00
Hendrik Liebau 4b66771895 Remove deprecated legacyBehavior and passHref prop from Link component (#83003)
The `legacyBehavior` prop of the `Link` component has been deprecated
since #77473. For Next.js 16, we're finally removing support for it.
Consequently, we're also removing support for the `passHref` prop, which
was only useful in conjunction with the `legacyBehavior` prop.

A [codemod is
available](https://nextjs.org/docs/app/guides/upgrading/codemods#new-link)
to help you automatically upgrade your codebase.

reverts #77473

---------

Co-authored-by: Sebastian Sebbie Silbermann <sebastian.silbermann@vercel.com>
2025-08-26 14:04:27 +02:00
P41T 8e8dd0c8c2 Update prettier project dependency from 3.2.5 to 3.6.2 (#82896)
What?
This PR updates the dependency "prettier" from version 3.2.5 to version
3.6.2. It also modifies other scripts by using the pnpm run prettier-fix
after updating the dependency.

Why?
This is updated to benefit from the changes and fixes introduced in the
newer versions of prettier, from versions 3.3 to 3.6.

How?
The package has been updated using pnpm install prettier@latest, and the
files other than package.json and pnpm-lock.json have been modified
using the script pnpm run prettier-fix.

This PR does only have formatting changes introduced by the updated
dependency
This PR is the same as #82719 , with fixes implemented to prevent
prettier to modifiy symlink files
2025-08-21 21:05:20 +00:00
Karthikeya Thatipamula 76ebbb9768 docs: add missing RLS step to Next.js tutorial (#82714)
## What
This PR updates
`examples/with-supabase/components/tutorial/fetch-data-steps.tsx` to
include a missing step about enabling Row Level Security (RLS) and
creating a simple read policy for the `notes` table.

Fixes: #82218

## Why
Currently, the tutorial shows how to:
- create a `notes` table
- insert data
- query data from Next.js

However, since RLS is enabled by default in Supabase, new users will get
`permission denied` errors when querying data unless they configure
policies.
The official Supabase Next.js quickstart docs already mention this:  
https://supabase.com/docs/guides/getting-started/quickstarts/nextjs

Adding this step will help newcomers understand why RLS is required and
how to set it up.

## Changes
- Added a new `<TutorialStep>` in `fetch-data-steps.tsx`:
  - Explains that RLS is enabled by default
  - Shows SQL snippet to enable RLS + create a public read policy
  - Links to the Supabase RLS docs

## Checklist
- [x] Added RLS tutorial step
- [x] Verified formatting matches other tutorial steps
- [x] Added links to relevant Supabase docs

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-08-20 22:46:26 +00:00
HAREESH BHITTAM 8dd5f48611 fix: update @types/node to resolve Vite 7.x peer dependency conflict (#82794)
## Problem
The project was experiencing npm dependency resolution conflicts when
running `npm install`, caused by incompatible @types/node versions
between Vite 7.1.3 and the existing project dependencies.

Fixes: https://github.com/vercel/next.js/issues/82779

**Error Details:**
- Vite 7.1.3 requires `@types/node@"^20.19.0 || >=22.12.0"`
- Project was using `@types/node@20.10.4`
- This created a peer dependency conflict, preventing clean installs

## Solution
Updated `@types/node` from `20.10.4` to a compatible version that
satisfies Vite 7.x requirements while maintaining compatibility with
Vitest 3.2.4.

## Changes Made
- Updated `@types/node` version in package.json
- Verified compatibility with all existing dependencies
- Confirmed tests still pass with deprecation warnings (React.act import
warnings - separate issue)

## Testing
- [x] `npm install` runs without errors
- [x] `npm test` passes all existing tests
- [x] No breaking changes to existing functionality

## Additional Notes
This fix resolves the immediate dependency conflict. The React.act
deprecation warnings in tests are a separate issue and should be
addressed in a future PR by updating test imports from
`react-dom/test-utils` to `react`.


Details Issue:
1]
npm test                      

> test
> vitest

The CJS build of Vite's Node API is deprecated. See
https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated
for more details.

DEV v1.0.4
/home/hareesh/learn-frontend/front-open-source/next.js/examples/with-vitest

stderr | app/blog/[slug]/page.test.tsx > App Router: Works with dynamic
route segments
Warning: `ReactDOMTestUtils.act` is deprecated in favor of `React.act`.
Import `act` from `react` instead of `react-dom/test-utils`. See
https://react.dev/warnings/react-dom-test-utils for more info.

stderr | app/page.test.tsx > App Router: Works with Server Components
Warning: `ReactDOMTestUtils.act` is deprecated in favor of `React.act`.
Import `act` from `react` instead of `react-dom/test-utils`. See
https://react.dev/warnings/react-dom-test-utils for more info.

stderr | app/counter.test.tsx > App Router: Works with Client Components
Warning: `ReactDOMTestUtils.act` is deprecated in favor of `React.act`.
Import `act` from `react` instead of `react-dom/test-utils`. See
https://react.dev/warnings/react-dom-test-utils for more info.

stderr | __tests__/Home.test.tsx > Pages Router
Warning: `ReactDOMTestUtils.act` is deprecated in favor of `React.act`.
Import `act` from `react` instead of `react-dom/test-utils`. See
https://react.dev/warnings/react-dom-test-utils for more info.

2]
npm install

npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: vite@7.1.3
npm error Found: @types/node@20.10.4
npm error node_modules/@types/node
npm error   dev @types/node@"20.10.4" from the root project
npm error peerOptional @types/node@"^18.0.0 || ^20.0.0 || >=22.0.0" from
vitest@3.2.4
npm error   node_modules/vitest
npm error     dev vitest@"^3.2.4" from the root project
npm error
npm error Could not resolve dependency:
npm error peerOptional @types/node@"^20.19.0 || >=22.12.0" from
vite@7.1.3
npm error node_modules/vite
npm error peer vite@"^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" from
@vitejs/plugin-react@4.7.0
npm error   node_modules/@vitejs/plugin-react
npm error     dev @vitejs/plugin-react@"^4.2.1" from the root project
npm error   vite@"^5.0.0 || ^6.0.0 || ^7.0.0-0" from vitest@3.2.4
npm error   node_modules/vitest
npm error     dev vitest@"^3.2.4" from the root project
npm error
npm error Conflicting peer dependency: @types/node@24.3.0
npm error node_modules/@types/node
npm error peerOptional @types/node@"^20.19.0 || >=22.12.0" from
vite@7.1.3
npm error   node_modules/vite
npm error peer vite@"^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" from
@vitejs/plugin-react@4.7.0
npm error     node_modules/@vitejs/plugin-react
npm error       dev @vitejs/plugin-react@"^4.2.1" from the root project
npm error     vite@"^5.0.0 || ^6.0.0 || ^7.0.0-0" from vitest@3.2.4
npm error     node_modules/vitest
npm error       dev vitest@"^3.2.4" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency
resolution.
npm error
npm error
npm error For a full report see:
npm error
/home/hareesh/.npm/_logs/2025-08-19T17_17_17_782Z-eresolve-report.txt
npm error A complete log of this run can be found in:
/home/hareesh/.npm/_logs/2025-08-19T17_17_17_782Z-debug-0.log

---------

Co-authored-by: Joseph <sephxd1234@gmail.com>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-08-20 14:57:22 +02:00
devin-ai-integration[bot] 9d3069adc7 docs: Improve Content Security Policy documentation (#80580)
# Improve Content Security Policy Documentation

This PR comprehensively improves the Next.js Content Security Policy
(CSP) documentation to address community feedback from Reddit and GitHub
discussions about gaps in the current documentation.

## Changes Made

### 1. Enhanced Nonce Flow Explanation
- Added detailed section explaining how Next.js automatically detects
and applies nonces during server-side rendering
- Clarified the 3-step process: middleware generation → Next.js
extraction → automatic application
- Explained that developers don't need to manually add nonces to every
script tag

### 2. Static vs Dynamic Rendering Documentation
- Added comprehensive section explaining performance implications of
using nonces
- Documented that nonces force all pages into dynamic rendering
- Explained trade-offs: slower page loads, increased server load, no CDN
caching
- Added guidance on when to use nonces vs alternatives

### 3. Experimental SRI (Subresource Integrity) Documentation
- Documented the experimental `sri.algorithm` configuration option
- Explained hash-based CSP as an alternative to nonces that preserves
static generation
- Included configuration examples and benefits/limitations
- Noted that SRI is webpack-only, App Router only, and experimental

### 4. Development vs Production Considerations
- Added section addressing environment-specific CSP requirements
- Documented need for `'unsafe-eval'` in development for HMR
- Provided conditional CSP examples based on NODE_ENV

### 5. Comprehensive Troubleshooting Section
- Added solutions for error pages that don't work with strict CSP
- Documented third-party script integration with CSP
- Included common CSP violation fixes
- Added examples for both App Router and Pages Router

### 6. Practical Examples
- Static site with hash-based CSP using SRI
- Dynamic site with nonce-based CSP
- Mixed approach for different page types
- Environment-aware CSP configuration

### 7. Enhanced Pages Router Documentation
- Added `_document.tsx` nonce access example
- Improved `getServerSideProps` examples
- Added third-party script integration examples

## Community Feedback Addressed

This PR directly addresses the Reddit thread feedback about:
- ❌ "it is not clear that the nonce is then picked up by the rest of the
pages" → ✅ Added detailed nonce flow explanation
- ❌ "it is not clear that the pages therefore are not statically
generated anymore" → ✅ Added static vs dynamic rendering section
- ❌ "The solution of being able to provide the sha256 hashes... is not
supported, and it is not mentioned in the documentation" → ✅ Added
experimental SRI documentation
- ❌ Poor documentation of strict CSP implementation → ✅ Added
comprehensive examples and troubleshooting

## Technical Details

- **File Modified**: `docs/01-app/02-guides/content-security-policy.mdx`
- **Lines Added**: 642 insertions
- **Maintains**: Existing documentation structure and Next.js
conventions
- **Supports**: Both App Router and Pages Router with appropriate
switcher components

## Testing

- Verified all code examples use correct Next.js APIs and patterns
- Ensured documentation follows existing Next.js docs structure
- Confirmed all referenced configuration options exist in the codebase
- Validated that experimental features are properly marked as such

---

**Link to Devin run**:
https://app.devin.ai/sessions/e7e5fa95dc0146b3ab79aac72c53ed13
**Requested by**: lee@vercel.com

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: lee@vercel.com <lee@vercel.com>
Co-authored-by: Joseph Chamochumbi <joseph.chamochumbi@vercel.com>
2025-08-04 18:47:26 +02:00
Remco Haszing 42bcacd9a1 Remove useMDXComponents argument (#80871)
### What?

Fix the signatures of `useMDXComponents`.

### Why?

The `useMDXComponents` function is always called without any arguments.
It’s also always supposed to be a named export, not a default export.
It’s also called during render. Defining React components during render
is an anti-pattern. All components that were previously defined inside
of `useMDXComponents`, are now defined outside of the function.

### How?

Manual fixes.

---------

Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
Co-authored-by: Joseph <sephxd1234@gmail.com>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-07-29 22:45:08 +02:00
nextjs-bot 92d1f0d915 Upgrade React from 19baee81-20250725 to eaee5308-20250728 (#82120) 2025-07-28 18:22:47 +00:00
Stojan Dimitrovski 8659d47c09 chore: Update with-supabase example to use getClaims() (#81383)
Updates the `with-supabase` example to use the new and much faster (when
project is configured with asymmetric JWT support)
`supabase.auth.getClaims()` function instead of `getUser()`.

---------

Co-authored-by: Benjamin Woodruff <benjamin.woodruff@vercel.com>
2025-07-15 15:31:46 -07:00
Ankur Datta 92a9d2840d Add Prisma ORM example to Next.js examples (#75290)
- A Next.js starter app using [Prisma
Postgres](https://www.prisma.io/postgres) and Prisma ORM

This PR adds a new example demonstrating how to integrate Prisma ORM
with a Next.js application. The example includes:

- Setup instructions for Prisma Postgres
- Example models and queries
- Basic CRUD operations using Prisma

---------

Co-authored-by: Nikolas <nikolas.burk@gmail.com>
Co-authored-by: Alex Martin <alex.martin@vercel.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2025-07-15 08:48:35 -07:00
Hendrik Liebau d7fa64ea3b Update eslint and restore .eslintrc.cli.json being used for CLI/CI-based linting (#81553)
This will allow us (again) to selectively use type-checked rules
internally, as stipulated in #67689. In a follow-up, we'll likely add
https://typescript-eslint.io/rules/switch-exhaustiveness-check/ as a
first type-checked rule.
2025-07-11 21:17:40 +02:00