Commit graph

117 commits

Author SHA1 Message Date
Loris Sigrist
732a64dda9
chore(docs): Update Inlang Link on Internationalization Page (#66488)
Hi 👋 Inlang dev here

This PR switches the Link to Inlang's i18n solution in the
Internationalization docs to point directly to
[Paraglide-Next](https://inlang.com/m/osslbuzt/paraglide-next-i18n)
since that's the most relevant page for NextJS developers looking for an
i18n library.

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

-->

Co-authored-by: Sam Ko <sam@vercel.com>
2024-06-03 18:43:31 +00:00
Niklas Arens
6278046116
docs: fix link for server components (#66470) 2024-06-02 09:13:05 -05:00
Delba de Oliveira
93c861d67b
Docs: Next.js 15 updates (#65603)
React 19
- [x] React Compiler
- [x] Check all examples for new API usage e.g.`useActionState`, `use`
- [x] Review Server Actions page and link to React docs.


Next.js 15

- [x] PPR incremental adoption and placeholder page - for SEO
- [x] `next/after`
- [x] Package bundling
- [x] Upgrade guide
- [x] Clarify new `fetch` behavior
- [x] Route handlers - dynamic 
- [x] Client-side router cache
- [x] Add "Good to know" about metadata route handlers being cached

15 and beyond
- [x] Remove recommendations for `revalidate = low value` 
- [x] Review and consolidate data fetching section
  - [ ] Client-side data fetching patterns 
    - [ ] Streaming data pattern with React `use`
    - [ ] Seeding initial data from the server

Redirects and blog post: https://github.com/vercel/front/pull/32249

---------

Co-authored-by: Ahmed Abdelbaset <A7med3bdulBaset@gmail.com>
Co-authored-by: Anthony Shew <anthonyshew@gmail.com>
Co-authored-by: Michael Novotny <manovotny@gmail.com>
Co-authored-by: Ethan Arrowood <ethan@arrowood.dev>
Co-authored-by: StephDietz <steph.dietz@vercel.com>
Co-authored-by: Stephanie Dietz <49788645+StephDietz@users.noreply.github.com>
Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2024-05-23 13:41:29 +00:00
Lee Robinson
a142012428
docs: clarify gSSP docs for runtime (#65962)
Replaces https://github.com/vercel/next.js/pull/65948.
2024-05-20 09:50:58 -05:00
Sam Ko
4d97acb27d
Revert "chore: externalize undici for bundling" (#65727)
## Why?

`undici` should be able to compile and bundle now.

- x-ref: https://github.com/vercel/next.js/pull/65243

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-05-14 15:11:09 +02:00
Steven
292fd4eb3f
feat!(next/image): change default Content-Disposition to attachment (#65631)
### BREAKING CHANGE

This changes the behavior of the default image `loader` so that
[`Content-Disposition`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#as_a_response_header_for_the_main_body)
header is now `attachment` for added protection since the API can serve
arbitrary remote images.

The new default value, `attachment`, forces the browser to download the
image when visiting directly. This is particularly important when
`dangerouslyAllowSVG` is true. Most users will not notice the change
since visiting pages won't behave any differently, only visiting images
directly.

Users can switch back to the old behavior by configuring `inline` in
next.config.js

```js
module.exports = {
  images: {
    contentDispositionType: 'inline',
  },
}
2024-05-10 21:35:48 -04:00
Ethan Arrowood
d0d22ac625
Promote and rename server bundling options serverComponentsExternalPackages and bundlePagesExternals (#65421)
This PR promotes and renames experimental configuration options related
to server bundling:
- `serverComponentsExternalPackages` -> `serverExternalPackages`
- `bundlePagesExternals` -> `bundlePagesRouterDependencies`

Existing docs for `serverComponentsExternalPackages` was changed. 
New docs for `bundlePagesRouterDependencies` were added.

Closes NEXT-3332
2024-05-07 11:19:35 -06:00
Steven
a6a6117197
feat(next/image)!: remove squoosh in favor of sharp as optional dependency (#63321)
## History

Previously, we added support for `squoosh` because it was a wasm
implementation that "just worked" on all platforms when running `next
dev` for the first time. However, it was slow so we always recommended
manually installing `sharp` for production use cases running `next
build` and `next start`.

Now that [`sharp` supports
webassembly](https://sharp.pixelplumbing.com/install#webassembly), we no
longer need to maintain `squoosh`, so it can be removed. We also don't
need to make the user install sharp manually because it can be installed
under `optionalDependencies`. I left it optional in case there was some
platform that still needed to manually install the wasm variant with
`npm install --cpu=wasm32 sharp` such as codesandbox/stackblitz (I don't
believe sharp has any fallback built in yet).

Since we can guarantee `sharp`, we can also remove `get-orientation` dep
and upgrade `image-size` dep.

I also moved an [existing `sharp`
test](https://github.com/vercel/next.js/pull/56674) into its own fixture
since it was unrelated to image optimization.

## Related Issues
- Fixes https://github.com/vercel/next.js/issues/41417
- Related https://github.com/vercel/next.js/pull/54670
- Related https://github.com/vercel/next.js/issues/54708
- Related https://github.com/vercel/next.js/issues/44804
- Related https://github.com/vercel/next.js/issues/48820
- Related https://github.com/vercel/next.js/pull/61810
- Related https://github.com/vercel/next.js/pull/61696
- Related https://github.com/vercel/next.js/issues/44685
- Closes https://github.com/vercel/next.js/issues/64362

## Breaking Change

This is a breaking change because newer versions of `sharp` no longer
support `yarn@1`.

- https://github.com/lovell/sharp/issues/3750

The workaround is to install with `yarn --ignore-engines` flag.

Also note that Vercel no longer defaults to yarn when no lockfile is
found

- https://github.com/vercel/vercel/pull/11131
- https://github.com/vercel/vercel/pull/11242

Closes NEXT-2823
2024-04-25 14:01:56 -04:00
Delba de Oliveira
84af8009e3
Docs: Explain why Layouts (RSCs) can't access pathname (#64785)
- Add section explaining why `pathname` can't be accessed in a layout
([file](https://github.com/vercel/next.js/pull/64785/files#diff-8eb7b23d3da342a1a407cdb6cc9c2d0dc2a455091ba2c4b6dbc41ba6cf840367))
- Split pages and layouts files (to add layout-specific examples in the
future)
- Clean up the existing active links example 

I'll add layout-specific examples in a follow-up PR, after creating some
demos.
2024-04-25 08:44:12 +01:00
Nils Jacobsen
ed15893814
docs: added inlang to the list of i18n community libraries (#61323)
Co-authored-by: Lee Robinson <me@leerob.io>
2024-04-22 16:07:16 -05:00
kxlow
9b77edee06
Fix optimizePackageImports docs for Pages Router (#64439)
The current documentation displays the docs for the `compress` option
instead of the `optimizePackageImports` option.


https://nextjs.org/docs/pages/api-reference/next-config-js/optimizePackageImports
2024-04-13 16:46:06 +00:00
Hung Doan
904908cf33
docs(pages): update slug value for optional catch all routes (#64381)
## Why?

When you do, →

```
  const router = useRouter()
  console.log('[test] router =', router.query.slug)
 ```
 
 the value of `router.query.slug` should be undefined in this instance.
 
 (screenshot from current docs)
![CleanShot 2024-04-13 at 00 18 14@2x](https://github.com/vercel/next.js/assets/28912696/6cd79b3e-9258-4fcb-8685-dc6fe4d336e8)

it should be `slug: undefined`.
2024-04-13 04:23:45 +00:00
Anatolii Kurochkin
fdeff57c7d
docs: clarify Internationalization (i18n) Routing (#63853)
## Description

Updated [Internationalization (i18n)
Routing](https://nextjs.org/docs/pages/building-your-application/routing/internationalization#leveraging-the-next_locale-cookie)
to clarify that `NEXT_LOCALE` does not override the `accept-language`
header value; rather, it prioritizes the `NEXT_LOCALE` cookie value over
`accept-language`.

## How has this been tested?

Ran `pnpm prettier-fix`
2024-04-12 18:56:08 +00:00
Vivek Kaushik
bf45353af1
Update 13-debugging.mdx (#64344)
This doc is outdated as mentioned as this issue has been going on for
years now where people are unable to debug/set breakpoints in VSCode due
to some mismatch of port/process configuration b/w VSC, Next/Node or
Browser(Chrome Dev tools).

Regardless, I found the fix on
https://github.com/vercel/next.js/issues/47561#issuecomment-1549241442
and it works like a charm.

Kindly update your docs accordingly. Thanks.

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

-->

---------

Co-authored-by: samcx <sam@vercel.com>
2024-04-12 15:55:02 +00:00
Zack Tanner
85b9ed5eb8
provide revalidateReason to getStaticProps (#64258)
Provides a `revalidateReason` argument to `getStaticProps` ("stale" |
"on-demand" | "build").

- Build indicates it was run at build time
- On-demand indicates it was run as a side effect of [on-demand
revalidation](https://nextjs.org/docs/pages/building-your-application/data-fetching/incremental-static-regeneration#on-demand-revalidation)
- Stale indicates the resource was considered stale (either due to being
in dev mode, or an expired revalidate period)

This will allow changing behavior based on the context in which it's
called.

Closes NEXT-1900
2024-04-09 09:53:08 -07:00
JJ Kasper
cf9e647f41
Auto map optimizePackageImports to transpilePackages for pages (#63537)
This ensures `optimizePackageImports` doesn't unexpectedly fail to apply
for `pages` as they aren't transpiled/bundled by default without either
`transpilePackages` being used or `experimental.bundlePagesExternals`.
This also ensures our docs correctly show this config in the pages docs
as currently in only shows in `app`.

x-ref: [slack
thread](https://vercel.slack.com/archives/C0676QZBWKS/p1710967294942029)

Closes NEXT-2884
2024-03-25 12:17:02 -07:00
tang
142b48f35c
Update 10-custom-server.mdx (#63543)
Add description that custom servers cannot be applied to standalone
output mode

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Steven <steven@ceriously.com>
2024-03-22 14:40:10 +00:00
이동현
3a1be97fed
chore(docs): update React docs link (#63594) 2024-03-22 14:35:58 +00:00
Delba de Oliveira
446083e21a
Docs: Document crossOrigin option (#61455) 2024-03-07 12:24:04 -06:00
Masato Nakamura
946c15fb2c
chore: Bump actions/cache (#62422)
<!-- 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 #

-->

GitHub is [planning to upgrade to Node
20](https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/).
Versions prior to actions/cache v3 use an outdated version of node, so
we will upgrade to actions/cache v4, where [Node 20 is the
default](https://github.com/actions/cache/releases/tag/v4.0.0).

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-02-23 08:05:17 +00:00
Lee Robinson
479faa7117
docs: migrating from CRA (#61866)
Co-authored-by: Michael Novotny <manovotny@gmail.com>
2024-02-09 19:32:53 -06:00
Jimmy Lai
feb27ad621
Revert "feat(next/image)!: remove squoosh in favor of sharp as optional dep" (#61810)
Reverts vercel/next.js#61696

Closes NEXT-2401
2024-02-08 11:00:34 +00:00
Steven
07c4ec052e
feat(next/image)!: remove squoosh in favor of sharp as optional dep (#61696)
## History

Previously, we added support for `squoosh` because it was a wasm
implementation that "just worked" on all platforms when running `next
dev` for the first time. However, it was slow so we always recommended
manually installing `sharp` for production use cases running `next
build` and `next start`.

Now that [`sharp` supports
webassembly](https://sharp.pixelplumbing.com/install#webassembly), we no
longer need to maintain `squoosh`, so it can be removed. We also don't
need to make the user install sharp manually because it can be installed
under `optionalDependencies`. I left it optional in case there was some
platform that still needed to manually install the wasm variant with
`npm install --cpu=wasm32 sharp` such as codesandbox/stackblitz (I don't
believe sharp has any fallback built in yet).

Since we can guarantee `sharp`, we can also remove `get-orientation` dep
and upgrade `image-size` dep.

I also moved an [existing `sharp`
test](https://github.com/vercel/next.js/pull/56674) into its own fixture
since it was unrelated to image optimization.

## Related Issues
- Fixes https://github.com/vercel/next.js/issues/41417
- Closes https://github.com/vercel/next.js/pull/54670
- Related https://github.com/vercel/next.js/issues/54708
- Related https://github.com/vercel/next.js/issues/44804
- Related https://github.com/vercel/next.js/issues/48820
2024-02-06 14:17:07 -05:00
Delba de Oliveira
91cbe61e75
Docs: Add instrumentation.ts API reference, improve instrumentation docs (#61403)
- Add instrumentation.ts API reference
- Polish and restructure instrumentation docs
2024-01-31 07:54:32 -06:00
Lee Robinson
c5d470a491
docs: fix Auth0 typo in authentication (#61171) 2024-01-25 23:20:00 +01:00
Lee Robinson
d7ff67de67
docs: Combine Pages/App authentication docs (#60848)
Co-authored-by: StephDietz <steph.dietz@vercel.com>
Co-authored-by: Stephanie Dietz <49788645+StephDietz@users.noreply.github.com>
2024-01-25 13:32:02 -06:00
Delba de Oliveira
2eaaad2d16
Docs: Share Redirecting docs with /pages (#61083)
- Share new **Redirecting** docs with /pages
- Add equivalent example for API routes in /pages
2024-01-24 08:23:38 -06:00
Mike Timmerman
6b88dc55ae
Update code example on 01-pages-and-layouts.mdx (#60963)
Use nullish coalescing operator in all getLayout examples on
documentation page

Co-authored-by: Sam Ko <sam@vercel.com>
2024-01-22 20:00:46 +00:00
Prachi Sharma
9cce76ac64
docs: updated the getStaticProps function name (#60949)
Fix: function name getStaticPaths is written in getStaticProps function,
issue exist in get-static-props.mdx under pages/api-reference/functions
folder. This issue was pushed as part of -
Pull Request: 55205
Commit Id: 80fba152f2add326a1520ffd2b530d00c75983f6


![image](https://github.com/vercel/next.js/assets/55828197/90923d4e-9d7b-4bc3-aaf9-7f5ce377410e)

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-01-21 21:11:20 +00:00
Lee Robinson
16dcebe792
Stabilize custom cache handlers and changing memory size. (#57953)
This PR stabilizes the previously introduced experimental config options
for providing a custom cache handler (for both ISR as well as the Data
Cache) and for disabling or configuring the in-memory cache size. The
example usage would be as follows:

```js
// next.config.js
module.exports = {
  cacheHandler: require.resolve('./cache-handler.js'),
  cacheMaxMemorySize: 0 // disable default in-memory caching
}
```

This PR also updates the documentation to better reflect how to use the
custom cache handler when self-hosting. Further information will be
added in a following PR that also includes a full example of a custom
cache handler that implements `revalidateTag` as well as passing in
custom cache tags. The API reference docs have been updated here, as
well as a version history added.

I also noticed that we currently have two duplicated versions of the ISR
docs in the Pages Router docs: both for rendering and for data fetching.
Data Fetching is the correct location for this page. There were no other
references to the rendering version in the docs, so that must have been
an accident. I'll need to a get a redirect going for that regardless.

Tests have been updated for `cacheHandler` and I added a new test for
`cacheMaxMemorySize`.

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-01-17 23:42:52 +01:00
Steven
1886478789
chore(docs): add docs for .svg unoptimized behavior (#60735)
- Fixes https://github.com/vercel/next.js/discussions/53041

Closes NEXT-2119

---------

Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
2024-01-16 15:06:42 -05:00
Clarence
60c07208dd
chore(docs/errors): Improve documentation grammar (#60452)
This PR fixes a couple of typos found in the docs/errors section

---------

Co-authored-by: Steven <steven@ceriously.com>
2024-01-10 16:48:29 +00:00
Steven
543ca11571
docs: update docs for remotePatterns to mention what happens when prop is omitted (#60387)
- Fixes #44660
2024-01-08 12:57:23 -05:00
Tobias
a95a7d684f
docs: Document error cases with head/body-tags (#56412)
Co-authored-by: Lee Robinson <me@leerob.io>
2024-01-06 11:16:21 -06:00
Stephanie Dietz
694bd3e21d
docs: Add "Going to production" page for App Router (#59304)
- Add **Going to Prod** docs for `app`
- Add bundle-analyzer page
- Merge `app` and `pages` docs

---------

Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Michael Novotny <manovotny@gmail.com>
Co-authored-by: Delba de Oliveira <delbabrown@gmail.com>
Co-authored-by: Rich Haines <hello@richardhaines.dev>
Co-authored-by: Lee Robinson <me@leerob.io>
2024-01-05 07:46:00 -06:00
vinay
3b64a53e59
docs: remove old links for examples (#57891)
Co-authored-by: Lee Robinson <me@leerob.io>
2023-12-24 09:47:16 -06:00
Nate Moore
2336274a2e
docs: Add cwd to VSCode debugging setup steps (#58689) 2023-12-22 16:26:04 -06:00
Loris Sigrist
19eea58d69
docs: Remove typesafe-i18n from third-party i18n options (#59624) 2023-12-22 16:14:25 -06:00
Jordan Newland
10a4ffcc10
docs: fix grammar issue in 03-get-server-side-props.mdx (#59670)
Hey Next.js Maintainers, 👋🏻

Quick PR to address a minor grammar error in the Pages docs.

Closes #59669

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-12-18 09:44:52 -08:00
David Agbenyega
1c3e305876
Docs: Review and Typo Fix - getServerSideProps (#59616)
<!-- 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 #

-->

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-12-18 09:30:18 -08:00
Lee Robinson
1c65c55750
docs: improve docs around geolocation and IP headers (#59719)
Based on feedback from https://github.com/vercel/next.js/issues/47793, I
made some improvements around the geolocation docs. Specifically around
`request.ip`, `request.geo`, and how to access these values. I noticed
there was a bit of a divergence, as some of the `NextRequest` and
`NextResponse` docs were split out for the App Router section, but not
all.

This PR finishes that swing by removing the previous catch-all for
`next/server` in the Pages Router docs and splits them into individual
docs pages.

Wrote a lil' thread about this:
https://twitter.com/leeerob/status/1736543599339172121

---------

Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
2023-12-18 07:55:48 -06:00
Lee Robinson
64d539fc50
docs: fix broken backtick for link (#59717)
<img width="764" alt="CleanShot 2023-12-17 at 11 25 10@2x"
src="https://github.com/vercel/next.js/assets/9113740/437a8a0d-0f56-4199-9629-b767569349de">
2023-12-17 09:53:59 -08:00
Lee Robinson
565c5b20b0
docs: small tweaks (#59638)
Just some random cleanup I wanted to do.
2023-12-16 14:13:17 -06:00
Delba de Oliveira
d2fd8f77ea
Docs: Review and update getServerSideProps page (#59545)
- Remove recommendation for client-side rendering
- Cut repetition 
- Improve tone
2023-12-13 20:42:28 -06:00
Delba de Oliveira
f518fd81b3
Docs: Fix formatting in testing docs and update examples dependencies (#59572)
Follow-up from: https://github.com/vercel/next.js/pull/59268
2023-12-13 07:02:53 -08:00
Delba de Oliveira
0ddc7e8fad
Docs: Add App Router Testing Guides and update /examples (#59268)
This PR updates the testing guides to use App Router and TypeScript,
also updates `/examples` to show `app` and `pages` examples.

## Overview

- [x] Create a new "Testing" section that is shared between `app` and
`pages`.
- [x] Explain the differences between E2E, unit testing, component
testing, etc.
- [x] Recommend E2E for `async` components as currently none of the
tools support it.
- [x] Update setup guides for **Cypress**, **Playwright**, and **Jest**
with latest config options, and examples for `app` and `pages`.
- [x] Add new guide for **Vitest**
- [x] Clean up `/examples`: use TS, show `app` and `pages` examples,
match docs config

## Cypress

- [x] E2E Tests
- [x] Component Testing
  - [x] Client Components
  - [x] Server Components
  - [ ] `async` components

**Blockers:** 
- TS: `Option 'bundler' can only be used when 'module' is set to
'es2015' or later`. In **tsconfig.json** compilerOptions, Next.js uses
"moduleResolution": "bundler", changing it to "node" fixes the issue but
it can have repercussions.
  - https://github.com/cypress-io/cypress/issues/27731 
- Version 14 is currently not supported for component testing
  - https://github.com/cypress-io/cypress/issues/28185

## Playwright

- [x] E2E Tests

## Jest

- [x] Unit Testing
   - [x] Client Components
   - [x] Server Components
- [ ] `async` components:
https://github.com/testing-library/react-testing-library/issues/1209
   - [x]  'server-only': https://github.com/vercel/next.js/pull/54891
- [x] Snapshot Testing

**Blockers:**
- TS: https://github.com/testing-library/jest-dom/issues/546
- None of the solutions in the issue work with Next.js v14.0.4 and TS v5

## Vitest 

- [x] Unit Testing
  - [x] Client Components
  - [x] Server Components
  - [ ] `async` components
  - [x] 'server-only'
 - [x] Update vitest example
- [x] Handles CSS, and CSS modules imports
- [x] Handles next/image

## Other

- https://github.com/vercel/next.js/issues/47448
- https://github.com/vercel/next.js/issues/47299
2023-12-12 22:30:23 -06:00
Delba de Oliveira
d5836a3038
Docs: Update Server Actions Docs (#59080)
- [x] Rename page from `forms-and-mutations` to
`server-actions-and-mutations` to account for examples that don't use
forms.
   - [x] Split `/pages` and `/app` content to make easier to edit 
- [x] Add Security Section
  - [x] Recommend tainting
  - [x] Closures and encryption
  - [x] Overwriting encryption keys
  - [x] CSRF protection | Allowed Origins
- [x] Add examples for Server Actions being called outside forms
  - [x] `useEffect`
  - [x] Event handlers
  - [ ] ~3rd party libraries~
- [x] More form examples
   - [x] Add note on calling actions in `<button>` and `<input> `
   - [x] Add `.bind` example | Recommend bind over hidden input field
 - [x] Recommend `try/catch` for error handling
- [x] Create `serverActions` next.config.js page 
   - [x] Document `allowedOrigins`
   - [x] Document `bodySizeLimit`
   - [x] Add note on Server Actions flag for < v14
- [x] Update error message links
- [x] Remove Server Actions from API reference as it's a React feature.
E.g. We don't have API references for Server Components.
- [ ] Set up redirects:

---------

Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Shu Ding <g@shud.in>
Co-authored-by: Michael Novotny <manovotny@gmail.com>
2023-12-07 15:12:25 -06:00
Jackie
d0159160dc
docs: update Firebase link to with-firebase example (#58621) 2023-12-05 21:33:14 -06:00
Jiwon Choi
caa05b4753
docs: Remove invalid URL (#58823)
This PR removes guidance to invalid URL
2023-12-05 21:30:27 -06:00
Delba de Oliveira
63a578f1c3
Docs: Fix upgrade guide files (#59249)
- Add v14 update guide to /app router docs
- Fix duplicate /upgrading folders
2023-12-04 08:55:46 -06:00