Commit graph

1306 commits

Author SHA1 Message Date
Lee Robinson
7424c4b6cd
Fix broken link in migration docs. (#41013)
https://vercel.com/templates/next.js/monorepo-turborepo
2022-09-29 02:35:09 +00:00
hashlash
ad613e4d3d
[Docs] Add useState and useEffect import (#40944)
It makes copy-pasting the code easier since the person will be aware of
the import

<!--
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 that you're making:
-->

## Documentation / Examples

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

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-09-27 12:51:32 -07:00
CJ Dunteman
b3b8836e17
[docs] Update Cypress config file name (#40849)
The latest version of Cypress no longer supports `cypress.json`, use `cypress.config.js` instead. See details in the Cypress [docs](https://docs.cypress.io/guides/references/configuration).
2022-09-23 20:46:12 +00:00
Maurício Mutte
cbe0407b8b
Update static-html-export.md (#40808)
This fixes anchor link in `static-html-export.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-09-22 20:37:41 +00:00
Philipp Bosch
f16992a156
docs: Remove extraneous FallbackComponent prop from error boundary docs (#40785)
It looks like the code snippet was copied over from
https://github.com/bvaughn/react-error-boundary but the `ErrorBoundary`
component on this docs page does not have a `FallbackComponent` prop but
renders the error message content itself.


## Documentation / Examples

- [X] Make sure the linting passes by running `pnpm lint`
- [X] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-09-22 09:04:44 -07:00
Rostyslav Melnychuk
4719517381
Updated example for i18n middleware (#40728)
Added support for search params and NEXT_LOCALE cookie if set

<!--
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 that you're making:
-->

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

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

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-09-20 15:48:55 -07:00
Steven Tey
f33c23c144
Added "negative matcher" documentation (#40282)
<!--
Thanks for opening a PR! Your contribution is much appreciated.
In order 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 that you're making:
-->

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-09-12 18:26:40 -07:00
Victor Boucher
3f2b4bc904
docs(basic-features/script): update script version history (#40263)
Made an addition to the version history within the Script component
docs. In the docs there are examples where the Script component is being
used within a _document.js/tsx file, but it does not get mentioned that
this is only supported from version 12.2.2 onwards.

## Documentation / Examples 
- [x] Make sure the linting passes by running `pnpm lint`

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-09-12 18:06:58 -07:00
JJ Kasper
8bf6a87303
Rename allowDynamic to unstable_allowDynamic (#40496)
Follow-up to https://github.com/vercel/next.js/pull/39539 as discussed
this renames to `unstable_` prefix initially while we test this out
further.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-09-12 15:32:18 -07:00
Damien Simonin Feugas
97ac344468
feat(edge): allows configuring Dynamic code execution guard (#39539)
### 📖  What's in there?

Dynamic code evaluation (`eval()`, `new Function()`, ...) is not
supported on the edge runtime, hence why we fail the build when
detecting such statement in the middleware or `experimental-edge` routes
at build time.

However, there could be false positives, which static analysis and
tree-shaking can not exclude:
- `qs` through these dependencies (get-intrinsic:
[source](https://github.com/ljharb/get-intrinsic/blob/main/index.js#L12))
- `function-bind`
([source](https://github.com/Raynos/function-bind/blob/master/implementation.js#L42))
- `has`
([source](https://github.com/tarruda/has/blob/master/src/index.js#L5))

This PR leverages the existing `config` export to let user allow some of
their files.
it’s meant for allowing users to import 3rd party modules who embed
dynamic code evaluation, but do not use it (because or code paths), and
can't be tree-shaked.

By default, it’s keeping the existing behavior: warn in dev, fails to
build.
If users allow dynamic code, and that code is reached at runtime, their
app stills breaks.

### 🧪 How to test?

- (existing) integration tests for disallowing dynamic code evaluation:
`pnpm testheadless --testPathPattern=runtime-dynamic`
- (new) integration tests for allowing dynamic code evaluation: `pnpm
testheadless --testPathPattern=runtime-configurable`
- (amended) production tests for validating the new configuration keys:
`pnpm testheadless --testPathPattern=config-validations`

To try it live, you could have an application such as:
```js
// lib/index.js
/* eslint-disable no-eval */
export function hasUnusedDynamic() {
  if ((() => false)()) {
    eval('100')
  }
}

export function hasDynamic() {
  eval('100')
}

// pages/index.jsx
export default function Page({ edgeRoute }) {
  return <p>{edgeRoute}</p>
}

export const getServerSideProps = async (req) => {
  const res = await fetch(`http://localhost:3000/api/route`)
  const data = await res.json()
  return { props: { edgeRoute: data.ok ? `Hi from the edge route` : '' } }
}

// pages/api/route.js
import { hasDynamic } from '../../lib'

export default async function handle() {
  hasDynamic()
  return Response.json({ ok: true })
}

export const config = { 
  runtime: 'experimental-edge' ,
  allowDynamic: '/lib/**'
}
```

Playing with `config.allowDynamic`, you should be able to:
- build the app even if it uses `eval()` (it will obviously fail at
runtime)
- build the app that _imports but does not use_ `eval()`
- run the app in dev, even if it uses `eval()` with no warning

### 🆙 Notes to reviewers

Before adding documentation and telemetry, I'd like to collect comments
on a couple of points:
- the overall design for this feature: is a list of globs useful and
easy enough?
- should the globs be relative to the application root (current
implementation) to to the edge route/middleware file?
- (especially to @sokra) is the implementation idiomatic enough? I've
leverage loaders to read the _entry point_ configuration once, then the
ModuleGraph to get it back during the parsing phase. I couldn't re-use
the existing `getExtractMetadata()` facility since it's happening late
after the parsing.
- there's a glitch with `import { ServerRuntime } from '../../types'` in
`get-page-static-info.ts`
([here](https://github.com/vercel/next.js/pull/39539/files#diff-cb7ac6392c3dd707c5edab159c3144ec114eafea92dad5d98f4eedfc612174d2L12)).
I had to use `next/types` because it was failing during lint. Any clue
why?

### ☑️ Checklist

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Documentation added
- [x] Telemetry added. In case of a feature if it's used or not.
- [x] Errors have helpful link attached, see `contributing.md`
2022-09-12 15:01:00 -07:00
M.K. Safi
d6f5ebf773
Clarify use of loading property (#40488)
I was a little confused by the `loading` property having the value `<header />`. I think that property is meant to show a loading state while the file is being loaded? If my assumption is correct, I think this change makes sense.
2022-09-12 18:31:23 +00:00
Balázs Orbán
735575708a
docs: move swcMinify: true out of "Experimental features" section (#40394)
See the blog post:
https://nextjs.org/blog/next-12-3##swc-minifier-stable

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-09-12 08:43:53 -07:00
Balázs Orbán
3851d9065f
docs(middleware): fix broken link 2022-09-12 13:13:09 +02:00
Lee Robinson
40fc066f09
Update Server Components documentation. (#40452)
This PR updates the server components documentation to make it more clear the benefit of server components and what their current status is inside Next.js.

It removes code snippets and CTAs for trying them out, as things have changed with the Layouts RFC since these docs were previously written. With the upcoming changes, server components will now be the default inside `app`. The list of supported and unsupported features was no longer accurate.

We will be providing more guidance as the layouts and routing changes are ready to be tested.

[Read the Layouts RFC](https://nextjs.org/blog/layouts-rfc) for more details.
2022-09-12 00:12:14 +00:00
Andrew Johnson
38169e3385
Fix mdx docs (#40402)
## Documentation / Examples

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

The MDX guide is missing `@mdx-js/react` as a required dependency in the
setup section.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-09-09 12:12:36 -07:00
Kiko Beats
a234abfae6
docs: fix middleware path (#40340)
Hello,

Just update the docs to be aligned with the current middleware implementation 🙂

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-09-08 21:27:17 +00:00
Jasham
ea33b84089
docs: fix typos (#40342)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-09-08 20:38:26 +00:00
Leon Si
0376534a29
docs: fix typo (#40354)
<!--
Thanks for opening a PR! Your contribution is much appreciated.
In order 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 that you're making:
-->

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-09-08 08:44:58 -07:00
Carl von Buelow
75e5616ce4
Update onLoadingComplete for next/future/image to receive reference to <img> (#40326)
* fixes #18398
* fixes #38864

Co-authored-by: Steven <steven@ceriously.com>
2022-09-08 08:37:41 -07:00
Steven
712d98d3d7
Update docs for remotePatterns image config (#40350)
This updates the docs to favor `remotePatterns` image config (instead of `domains`)
2022-09-08 11:19:55 -04:00
Balázs Orbán
b8d913295f
docs: fix numbering in middleware docs (#40276)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-09-07 00:08:00 +00:00
Alex Castle
6cc8dc38df
Change sizes docs to use max-width in media query (#40290)
This PR updates the next/image and `next/future/image` sizes docs to use `max-width` in the `sizes` media query, for code style and consistency reasons.
2022-09-06 23:36:16 +00:00
Alex Castle
815abc5e05
Change image sizes docs to use em instead of px (#40288)
This PR is a minor change to the image docs (`next/image` and `next/future/image`). The example sizes media queries are switched from `em` to `px` for readability.
2022-09-06 22:28:34 +00:00
sumiren
5c2faad36e
docs: update get-static-paths.md (#40205)
I found that `fallback: true` behaves like `fallback: blocking` when client-side page transition, but document doesn't mention the behavior.
I tried following.

* created a SSG page which has getStaticPaths and getStaticProps, and the getStaticProps is too slow(something like `await setTimeout(10000)`)
* `next build && next start`, not `next dev`
* tried page reload and client-side page transition both

getServerSideProps document explains about client-side page transition.
https://nextjs.org/docs/basic-features/data-fetching/get-server-side-props#when-does-getserversideprops-run

On the other hand, getStaticPaths didn't explain this behavior, so I added it.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-09-06 16:16:49 +00:00
Damien Simonin Feugas
866de41681
docs: documents middleware matcher (#40180)
### 📖 What's in there?

Middleware matchers are powerful, but very few people realized it, because they are not really documented.
This PR tries to bring more clarity, and includes a more advanced example.

The example shows how to exclude several pages (no `/static`, no `/public`), but also allow specific page in excluded paths (`/public/disclaimer`)

### 🧪 How to test?

Run the example: `pnpm next dev examples/middleware-matcher`, then browse to http://localhost:3000
The first 3 links should not match, the last 3 ones should.

Don't forget to clear your localhost cookies if you change the middleware code.

### 🆙 Note to reviewers

Using session cookies to pass information from middleware to the rendered page is not great, because `document.cookie` is not available during SSR, and because cookies persist when refreshing the page (making it hard to try different matchers)

However, I couldn't find a simpler way to convey the information from the middleware to the page, and I meant to have something visual. The other option is to use response headers and curl commands, but...
2022-09-05 13:36:09 +00:00
Steven
4cc7f11da2
Update to stable: next/future/image, remotePatterns, unoptimized (#40142)
This PR updates a few features from experimental to stable status:

- `next/future/image` component
- `remotePatterns` configuration
- `unoptimized` configuration
2022-08-31 22:44:17 +00:00
Ken aka Frosty
e7e567b1fc
[docs] Functional syntax for _document example in Basic Features: Font Optimization (#40140)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [X] Make sure the linting passes by running `pnpm lint`
- [X] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-08-31 19:46:55 +00:00
Steven
abddee7413
Change alt to required in next/future/image (#40136)
This `alt` attribute is required by `<img>` according to the HTML spec, so we should also make it required for `next/future/image`. In the cases where it is not needed, it can be set to the empty string.

https://html.spec.whatwg.org/multipage/images.html#alt
2022-08-31 19:10:19 +00:00
Kévin Dunglas
591f341d82
docs(security-headers): interest-cohort has been replaced by browsing-topics (#40113)
See https://github.com/mdn/browser-compat-data/issues/9814

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-08-31 02:01:25 +00:00
Dueen Eduarda
b760c8dd0a
docs(image): Use hook inside of function component (#40096)
The example broke the [Rules of Hooks](https://reactjs.org/warnings/invalid-hook-call-warning.html#:~:text=Hooks%20can%20only%20be%20called%20inside%20the%20body%20of%20a%20function%20component.) by calling the hook outside of the function component.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-08-30 10:22:55 -05:00
Jesús Ferretti
1bf2ab6a66
docs(testing): add JSDoc typing in jest.config.js (#40090)
This PR improves the Testing documentation in [Setting up Jest (with the Rust Compiler)](https://nextjs.org/docs/testing#setting-up-jest-with-the-rust-compiler). It adds JSDoc typing in `jest.config.js`.

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
2022-08-30 14:38:29 +00:00
YK
fdb629d01e
Update debugging.md (--dev -> --save-dev for npm) (#39998)
Reference:
https://docs.npmjs.com/specifying-dependencies-and-devdependencies-in-a-package-json-file#adding-dependencies-to-a-packagejson-file-from-the-command-line

## Documentation / Examples

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

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-08-29 12:42:46 -05:00
Yoann Moinet
1b61d1f5df
[docs] Add precision about pageExtensions (#40016)
Adding a precision because when you change the `pageExtensions` configuration in `next.config.js`, `middleware.ts` isn't recognized anymore.

Took me some time to debug this one, not sure if it should be considered a bug or just lack of documentation.
I'll let you be the judge of that.

## Documentation / Examples

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


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-08-28 21:34:59 +00:00
Sanjaiyan Parthipan
ca807d66f9
Update script.md (#40017)
Adding id property for inline script 

Co-authored-by: Sukka <isukkaw@gmail.com>
2022-08-28 13:42:11 -05:00
Adil Amanat
e5997dce72
Update image.md (#39984)
Update the cache behavior with the correct Header name. Updated header name from `x-nextjs-cache` to `x-vercel-cache`

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-08-26 15:26:47 -05:00
Lee Robinson
060812a11a
Revert "Adds note about custom server requirements" (#39956)
Reverts vercel/next.js#39931

Let's instead add this to the custom server documentation, in a section on "Using Middleware". Since such a low percentage of folks eject out of the default server, this shouldn't be so high up on the Middleware docs page.
2022-08-26 08:59:57 +00:00
Lee Robinson
d267c300fa
[docs] Update UTM params of some links (#39951)
Noticed a few outdated links, plus some that have since had redirects added, so took this opportunity to make the UTM params consistent 👍
2022-08-25 21:15:37 +00:00
Lee Robinson
c4a240d981
Update Font Optimization docs (#39950)
This makes it more clear that using Document is recommended for the best font experience, versus manually adding it every page. More updates coming to this page in the future as we add support for more features here.
2022-08-25 20:29:56 +00:00
Mosaad
9a7a8acc64
fix hash-link (#39929) 2022-08-25 15:42:45 +00:00
Esben Anker-Møller
a9772b1310
Adds note about custom server requirements (#39931)
This wasn't obvious to me when trying out middleware in our project, and the error message was `Invalid URL` - took me embarrassingly long to remember that we run a custom server. Would it be possibly to detect that middleware is used and then throw a descriptive error message when trying to call `next` without `hostname` and `port` in a custom server? If someone can point me to where that could be done, I would be happy to make a pull request.

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`

I made the change in Github ui, so couldn't run `pnpm lint`. Is this automated or should I clone and run it locally?
2022-08-25 14:39:31 +00:00
Simon Gavelin
3da768f839
[docs] Fixed 404 links to Layouts RFC blog post (#39937)
Fixes broken links to Next.js Router and Layouts RFC blog post


## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
2022-08-25 14:21:39 +00:00
Hannes Bornö
ca9fef6ef6
Docs: Updated note about using next/head in basic-features/font-optimization (#39863)
## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-08-23 09:15:09 -05:00
Steven
7e9f9bfbef
Fix onError handling in next/future/image (#39824)
This PR fixes a race condition where the `onError` handler was never called because the error happened before react attached the error handler.
2022-08-22 21:37:16 +00:00
sumiren
6bc7cdaf47
doc: improve a word client side rendering (#39771)
The term client-side rendering is ambiguous and misleading.
Some people would assume the architecture where a blank page is returned from the server and HTML generation is totally done on the frontend.

So I changed the term to `client-side data fetching`, which is widely used throughout the rest of the document.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-08-22 14:55:46 -05:00
Arthur Denner
d2ab9bcc85
Mention router.isPreview on Preview Mode page (#39830)
The documentation is concise and straightforward, so I just added a sentence.
Let me know if you'd like to describe more, add an example, etc.

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-08-22 19:46:54 +00:00
Steven
b6bbbc813f
Update docs next/future/image with details about computed aspect ratio (#39829)
The browser support for this feature was added to caniuse so we can link there instead of linking to each browser bug tracker.
2022-08-22 17:31:57 +00:00
Adrian Bienias
8f023992a2
Update links to point to more accurate docs (#39818)
Initial links were pointing to basic features which don't describe redirections.
2022-08-22 14:01:14 +00:00
Maedah Batool
e307096e2f
Add clarity in docs for using exportPathMap with getStaticPaths (#39813)
This PR adds a warning note for using the exportPathMap function with getStaticPaths. Any routes defined with EPM will get overridden if that page uses GSP.
Bug

 Related issues linked using #534
 Integration tests added
 Errors have helpful link attached, see contributing.md

Feature

 Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
 Related issues linked using fixes #number
 Integration tests added
 Documentation added
 Telemetry added. In case of a feature if it's used or not.
 Errors have helpful link attached, see contributing.md

Documentation / Examples

 Make sure the linting passes by running pnpm lint
 The examples guidelines are followed from our contributing doc
2022-08-22 08:50:56 -05:00
Dave Welsh
8bc93d0209
Typescript Documentation Improvement for Persistent Layouts (#33659)
By making `NextPageWithLayout` generic and passing the type parameters to `NextPage`, our pages can continue to specify the props explicitly. This gives us type safety in `getInitialProps`, for example.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-08-22 09:42:24 +00:00
Faris Masad
63651a63de
Add note about using the /_error page directly to custom error page article (#39671)
See https://github.com/vercel/next.js/issues/39144

It's not completely clear that `/_error` should not be used as a normal page. Added a note under `Caveats` in the custom error page article
2022-08-22 02:30:18 +00:00
greeble
1ebd6a1d94
Update next.js.configs line number (#39802) 2022-08-21 22:16:23 +00:00
Steven
5b6631a5c9
Add section to next/future/image docs about Known Browser Bugs (#39759)
This PR adds section to `next/future/image` docs about Known Browser Bugs. This also includes workarounds that might vary depending on the image and how the user plans to use it.
2022-08-20 00:21:00 +00:00
Delba de Oliveira
ee134ee338
Change the React Server Components CTA to the router/layout RFC (#39724) 2022-08-18 14:23:10 +00:00
Muhammad Musa
f743aa1833
Update strategies count to 4 (#39610)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-08-15 18:37:19 +00:00
Andrew Cherniavskii
d9a1c4315e
[docs] Avoid next config validation warning (#39554)
[docs] avoid next config validation warning
2022-08-12 10:54:57 -05:00
Bennett Dams
9d1980d086
docs: Rename API middlewares title in sidebar (#39534)
Based on the PR #39407, the sidebar title for API middlewares is changed from "API Middlewares" to "Request Helpers".




## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-08-12 13:55:39 +00:00
Noel Kim (김민혁)
40f0eb126b
feat(next-swc/modularize_imports): Add Kebab case (#38583)
* Feat: Add Kebab case

* Add document

* Feat: Add Kebab case

* Add document

* Add Test cases
2022-08-10 22:51:05 -05:00
Maedah Batool
bd61406e54
Improve next/future/image Migration docs (#39421)
The [comparison table for migration](https://nextjs.org/docs/api-reference/next/future/image#migration) to `next/future/image` looks odd layout-wise. The issue was brought up via this [Slack thread](https://vercel.slack.com/archives/C02F56A54LU/p1660040275310949).

This PR makes this improvement.

### New implementation

<img width="1216" alt="image" src="https://user-images.githubusercontent.com/12712988/183631902-6850836b-cb4e-44ea-909f-ba353725be15.png">

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)


Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2022-08-10 20:40:53 +00:00
Jono Hewitt
7d59da97ac
Update router.prefetch documentation to include locale option (#39442)
* Update `router.prefetch` documentation

Include documentation for setting the locale as an option within `router.prefetch`.

* apply suggestions

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-08-09 21:02:55 -05:00
Alex Castle
e2119c068f
Add component wrapper in sizes documentation code snippet (#39437)
* Wrap sizes code snippets in component

* Don't remove docs import statement
2022-08-09 15:43:25 -05:00
Alex Castle
b2d93e8a84
Enhance sizes documentation for next/image (#39301)
This PR updates the documentation for the `sizes` proper in next/image to make it more clear what this prop does and why it's (very) important to use it. After feedback, I'll update this PR to also modify the future image component docs.


Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-08-09 19:30:49 +00:00
fediev
d3bbfea117
Improve description of context.query in getServerSideProps() (#39422)
Improve description of `query`

`query` is not just representing of the query string. It has the same values as `router.query`.
2022-08-09 10:23:54 -05:00
Lee Robinson
5d93753bc3
API Routes Request Helpers docs. (#39407)
Renames Middleware to Request Helpers to be both more accurate and also less confusing since Middleware is a separate feature of Next.js now.
2022-08-09 02:02:14 +00:00
Sanjaiyan Parthipan
1cc6e47abe
Update script.md (#39400)
Adding `strategy="lazyOnload"` for prevent minor confusion.

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-08-08 18:03:23 +00:00
sumiren
9f8713fae4
docs: update When section of getStaticProps page (#39393)
getStaticProps will be called in conjection with fallback.

it's written in following page, but not in concerned page.
https://nextjs.org/docs/basic-features/data-fetching/get-static-paths
2022-08-08 10:20:12 -05:00
Lucas Rosa
a5029e9fd4
Allow custom path for preview mode cookies (#38313)
* Allow custom path for preview mode cookies

* update params order and tests

* update tests

* fix tests and update docs

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-08-07 20:45:30 -05:00
Cupid Valentine
6b49d4744c
docs: add missing dot (#39314)
Co-authored-by: spcma <46758907+spcma@users.noreply.github.com>



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-08-04 02:38:03 +00:00
Alex Castle
2f49a4f930
Remove default setting for object-fit on future fill images (#39297)
This PR removes the default styling of `object-fit:"contain"` for images using the future image component. This means images will get the default `object-fit` behavior of `"fill"`.

The main reason for this change is that an inline style will take precedence over external CSS, making this default behavior difficult to override with some styling strategies.


Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2022-08-03 19:22:27 +00:00
hiro
498d1e939a
fix typo: docs/advanced-features/react-18/streaming.md (#39293)
fix typo document.
2022-08-03 18:18:25 +00:00
Josh Parnham
a1895424c5
[docs] Clarify polyfill support (#39272)
Currently next.js polyfills a [subset](https://github.com/vercel/next.js/blob/canary/packages/next-polyfill-nomodule/src/index.js) of APIs for `nomodule` browsers (such as IE 11), however it's not immediately clear to developers which APIs are transparently polyfilled.

For example, currently `Object.entries` is polyfilled and thus is usable in IE 11, but [it was decided](https://github.com/vercel/next.js/pull/15772#discussion_r463984612) that `Object.fromEntries` should not be polyfilled. As a developer, this is a confusing situation until you end up finding the `next-polyfill-nomodule` list of polyfills that are included.

This PR attempts to improve the Supported Browser Features page by:
- linking to the list of polyfills
- clarifying that custom polyfills are required for IE11 (and other old browser) compatibility
- moving the section on Sever-Side polyfills further down the page so all browser polyfill sections are better grouped together

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-08-03 16:26:52 +00:00
Steven
213c42f446
Add section about migrating from next/image to next/future/image (#39270)
This expands on the previous PR #38978 with a section on migrating
2022-08-02 23:23:10 +00:00
Matt DuLeone
0e5a0ec4e0
Clear up rewrites documentation (#39238)
## Documentation / Examples

This PR specifically calls out in more clear language how the rewrites function behaves. This tripped me up recently as I recently came looking for more information, and the documentation left me with more questions than answers. This is an attempt to clear up the confusion I walked away with for anyone who comes in after me.

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-08-02 02:18:21 +00:00
Alex Castle
cbaaaeb076
Add "fill" mode to next/future/image (#38855)
This PR adds a `fill` attribute to the future image component, that behave similarly to the fill mode on the existing image component.

Functionally, it mainly adds `position: "absolute"` and `object-fit: "contain"` to the image element, along with `height: "100%"` and `width: "100%"` to preserve the image aspect ratio. All of these can be overwritten by the user, except for `position: "absolute"`, which will throw an error. This is because changing that property without height and width is likely to cause layout shift.

Because we no longer have the wrapper element, this new version of `fill` requires that the user set `overflow: "hidden"` on the parent element themself, if they want that behavior.

This PR also includes several runtime checks to catch instances where the fill mode may provide unexpected results. These runtime checks warn if:
* The image doesn't have the `sizes` attribute and loads much smaller than the viewport
* The containing element does not have `position: "relative"`
* The image height value is 0

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2022-08-01 18:21:36 +00:00
NikhilNama18
f0df2c274d
Replaces getStaticProps with getStaticPaths (#39218)
In `Generating paths on-demand` section 
It was mentioned that `getStaticProps` allows you to control which pages are generated during the build. 
But `getStaticPaths` will allows us to control which pages are generated during the build.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-08-01 12:48:06 +00:00
Santi Dalmasso
de6fc1cf35
fix: Update testing.md (#39195)
Update `e2e/example.spec.ts` ([/docs/testing](https://nextjs.org/docs/testing#creating-your-first-playwright-end-to-end-test) page) to fix the failed test. Fixes: #39194
## Bug

- [ ] Related issues linked using fixes #number
- [ ]  Integration tests added
- [ ]  Errors have helpful link attached, see contributing.md

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ]  Related issues linked using fixes #number
- [ ]  Integration tests added
- [X]  Documentation added
- [ ]  Telemetry added. In case of a feature if it's used or not.
- [ ]  Errors have helpful link attached, see contributing.md

## Documentation / Examples

- [ ] Make sure the linting passes by running pnpm lint
- [ ]  The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md?rgh-link-date=2022-07-13T09%3A09%3A13Z#adding-examples)
2022-07-31 15:30:38 +00:00
JJ Kasper
cf729edc9d
Add caveat note about shallow routing with middleware (#39154) 2022-07-28 21:28:34 -05:00
Houssein Djirdeh
a8186065b8
[Script] Adds onReady prop to next/script (#38849)
Closes: #30962

This PR adds a new `onReady` prop to `next/script` to handle shortcomings of the current `onLoad` prop. Some third-party providers and widgets require initialization code to run after the script's `load` event and every time the component is mounted. The `onReady` should solve that use case.

For more details, refer to the discussion in #30962.

CC @janicklas-ralph

## Bug

- [X] Related issues linked using `fixes #number`
- [X] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-07-28 20:42:52 +00:00
Lee Robinson
c3fd9e4eec
Add note to next/future/image about default styles. (#38978) 2022-07-25 02:53:39 +00:00
Didi Keke
413d35b75e
docs: update typescript.md (#38717)
"You [SHOULD NOT](https://datatracker.ietf.org/doc/html/rfc2119#section-4) remove ~n~or edit it" in place of "You cannot remove it or edit it".
Rational:
- It is a strong recommendation; not a weak possibility.
- ~Both actions have a negative connotation; as such, it is appropriate to use "nor"~.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

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


Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2022-07-25 01:39:46 +00:00
Michael Carr
8365bf62df
Docs: Fix grammatical typo (#38962)
Fixes grammatical typo found on line 73 of `docs/basic-features/data-fetching/get-static-paths`



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-07-24 03:12:10 +00:00
Lee Robinson
8b721227cf
Add section about building getStaticPaths on-demand. (#38943)
Based on feedback from here: https://twitter.com/leeerob/status/1550617876188520452

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-07-23 05:16:16 +00:00
Michael Squitieri
98f4bdd12d
Remove next-page-tester from testing.md (#38920)
Next Page Tester has officially been deprecated.
2022-07-22 10:22:24 -05:00
Jiachi Liu
f086283e38
Remove the next/streaming endpoint and experimental refresh api (#38837)
Drop the `next/streaming` endpoint. Currently it only holds the only one experimental api and we'd like to deprecate it in favor of oher future APIs for app dir
2022-07-20 22:41:48 +00:00
Balázs Orbán
9416e00bb1
docs: improve wording on pathname and asPath (#38835)
* Update router.md

* Update router.md
2022-07-20 10:30:06 -05:00
Houssein Djirdeh
81c3cd682b
[ESLint] Make src/ a default linting directory (#38810)
Fixes #38533 by including `src/` as a default linting directory where all files within are linted

## Bug

- [X] Related issues linked using `fixes #number`
- [X] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-07-19 20:58:13 +00:00
Isaac Martin
b9791bf999
update fallback docs (#38659)
* update fallback docs

* minor update

* Apply suggestions from code review

Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-07-18 13:19:29 -05:00
Dorian
7280c3ced1
Update get-static-props.md (#38703)
Update the file name in the import statement in the "write server-side code directly" section in the documentation
2022-07-16 04:05:33 +00:00
You Nguyen
bbbbe20c99
Add bundlejs site (#38677)
Add [bundlejs](https://bundlejs.com/) site - an online tool to quickly bundle & minify your projects, while viewing the compressed gzip/brotli bundle size, all running locally on your browser.

The lowercase name is intentional.
2022-07-15 16:06:54 +00:00
Lee Robinson
b1bb3d94c6
Add documentation on accessibility. (#38522)
This PR outlines the built-in features of Next.js that help make your application accessible, and will also include some resources for testing/improving accessibility in your app.

Related: https://github.com/vercel/next.js/pull/20428
2022-07-14 13:05:39 +00:00
Balázs Orbán
b0d64d647a
docs: clarify that matcher needs to be constant values (#38597)
Ref: #38461, #37346

As [introduced](https://github.com/vercel/next.js/pull/37177/files#diff-7ec7f47987bd890b5b47f6cf101398cd22fa37f874348d70036f85309a040c92
) in #37177, we statically analyze the `matcher` values, so we should make it clear.


## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-07-13 14:36:10 +00:00
Myeonghwan Cho
9664c8d054
Add missing closing curly bracket in compiler option example (#38586)
This PR adds a missing closing curly bracket in the compiler option example of the [Styled Components](https://nextjs.org/docs/advanced-features/compiler#styled-components).

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [X] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-07-13 14:16:00 +00:00
Steven
11825da7ed
Update docs for next/future/image with browser support (#38563)
* Update docs for `next/future/image` with browser support

* Mention blur constraints
2022-07-12 13:25:11 -05:00
Steven Tey
38a0276d28
[DOCS]: Middleware doesn't execute for on-demand ISR (#38562)
Updated docs to reflect that



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)


Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2022-07-12 17:06:43 +00:00
Daniel Cavanagh
3075c3ff71
Note about manually passing props from custom app (#37329)
I've wasted a couple of hours trying to work out why my static build wasn't passing through the props automatically as the docs say it should

Turns out it's the default app doing that and a custom app has to manually passed the props through

It wasn't obvious to me to look in the custom app doc where it's mentioned, so I've added a small note to the `getStaticProps` doc about this that points to the custom app doc

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-07-11 22:26:12 +00:00
JJ Kasper
1c1fbeb4de
Add note about standalone + runtimeConfig caveat (#38532)
## Documentation / Examples

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

x-ref: https://github.com/vercel/next.js/issues/38119
2022-07-11 21:51:26 +00:00
Cupid Valentine
7e47b861d5
Update api-middlewares.md (#38499)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-07-11 11:18:56 +00:00
Houssein Djirdeh
5155a88ab0
[Docs] Adds mention of INP to "Measuring Performance" page (#38464)
* adds mention of inp to measuring performance docs

* lint-fix

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-07-08 15:00:01 -05:00
Lee Robinson
979da91369
Update i18n routing example with Middleware. (#38419)
https://github.com/vercel/next.js/discussions/18419#discussioncomment-3092971

Co-authored-by: Balázs Orbán <18369201+balazsorban44@users.noreply.github.com>
2022-07-08 09:39:44 +00:00
mongolyy
ca0f1da92d
Update building-form sample code (#38437)
I found discrepancy between sample code and description.

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-07-08 03:18:59 +00:00
JJ Kasper
93cb635e9e
Add note about casing to getStaticPaths docs (#38426)
x-ref: [slack thread](https://vercel.slack.com/archives/CGU8HUTUH/p1656942759965239)

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-07-07 20:03:45 +00:00
Zane Chua
3b3d249c48
Update edge-runtime.md (#38271)
* Update edge-runtime.md

* Update docs/api-reference/edge-runtime.md

* fix linting

Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-07-06 14:13:17 -05:00
Marius Jørgensen
3ae343fa90
Fix/update docs for swc styled components (#38280)
According to https://github.com/vercel/next.js/issues/30802 SWC transforms for `styled-components` were updated with support for `cssProp`, `fileName` and `namespace`. The docs only mention support for `ssr` and `displayName`.

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
2022-07-06 19:00:17 +00:00
Armand Abric
fa1261cbfb
Fix typo in SWC plugin destructuring example (#38367)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

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


Co-authored-by: Balázs Orbán <18369201+balazsorban44@users.noreply.github.com>
2022-07-06 13:39:36 +00:00
Ryan "Haticus" Huellen
20c1079e96
Clarification for Testing Environment Variables (#38359)
## Documentation / Examples

- [X] Make sure the linting passes by running `pnpm lint`
- [X] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)

## The Issue
When it came to testing environment variables with jest in the current release of NextJS, I ran into an issue where my variables were seemingly undefined for no reason. With some research and the help from a friend in discussion post #38353 it was determined further configuration steps were needed in relation to the environment variables for jest. At the time being, no direct link is made between [Setting up Jest](https://nextjs.org/docs/testing#setting-up-jest-with-the-rust-compiler) and [Test Environment Variables](https://nextjs.org/docs/basic-features/environment-variables#test-environment-variables).

## The Change
This fix provides further clarification on the issue by creating a new link within the note on the [Setting up Jest](https://nextjs.org/docs/basic-features/environment-variables#test-environment-variables) page. Moreover, further explanations were added to ensure developers understand the `test` environment is completely separate from both `development` and `production` meaning files like `.env.development` and `env.prodution` won't be recognized when testing.

## Supporting Documentation
This is an issue time and time again for developers. Not only have I experienced this, but others have asked on both [GitHub Discussions](https://github.com/vercel/next.js/discussions/16270) and [StackOverflow](https://stackoverflow.com/questions/63934104/environment-variables-undefined-in-nextjs-when-running-jest/67997819#67997819). Moreover, many of the solutions from 2020 no longer work properly.

I hope this is sufficient enough for a contribution to the documentation. Minor improvements like these create the ideal developer experience Next.js is known for. :)


Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2022-07-06 02:39:11 +00:00
Cupid Valentine
09fdf9ada1
Update get-static-props.md (#38287)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-07-05 19:50:49 +00:00
Lee Robinson
a5e11612c7
Update next/future/image docs to specify supported browser versions. (#38307)
This adds more specificity to what browsers are supported for the underlying web-native features.
2022-07-05 13:49:04 +00:00
Carsten Lebek
beaa4df9fc
Typo in NextResponse docs (#38259)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-07-03 22:18:41 +00:00
Balázs Orbán
f3659a5f93
docs: remove eslint config link (#38206)
[Slack thread](https://vercel.slack.com/archives/C02UJ0QH45Q/p1656580818197009)

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-30 14:56:05 +00:00
Alan Pledger
90deca9509
Add a Makeswift example (#38018) 2022-06-29 13:25:51 -05:00
Pakapon Kaewmark
9aa282b4a8
Remove lazyRoot example from next/future/image doc (#38140)
According to the 12.2 release note and the source code, the `next/future/image` does not use `IntersectionObserver` anymore so the `lazyRoot` prop is also not used.
The example probably got left behind unintentionally.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [X] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-29 12:50:17 +00:00
Jesse Jafa
89c57cd867
Clarify router.query initial value during prerendering (#38093)
AFAIK router.query will still be an empty object during prerendering if you have `getStaticProps`. It will be its "correct" value during prerendering if  you're using `getServerSideProps` so this change seems to more accurately describe `router.query`
2022-06-29 11:40:12 +00:00
Michael Novotny
c83f94cf8b
Readds missing @next/next/no-assign-module-variable ESLint rule. (#38134)
Readds `@next/next/no-assign-module-variable` ESLint rule that was inadvertently removed in #34335 during the resolution of many merge conflicts.

This PR will get us back to a good / working state. I'll see if I can add a test to ensure all rule are accounted for in a separate PR.

Fixes #34335.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-29 02:54:47 +00:00
Steven
350d4cb879
Update next/future/image docs to mention the difference with next/image (#38108)
This PR update the `next/future/image` docs to mention the difference with `next/image`
2022-06-28 15:43:30 +00:00
JJ Kasper
8e161e1855
Middleware docs update (#38111)
* Initial outline added for middleware docs

* Feedback changes - not included new user agent yet

* edge api routes docs

* middleware page some cleanup

* moved api stuff to next server, added useragent

* waitUntil example added

* Updated env vars section

* Added cookies on the request object example

* fixed naming

* fixed import typo

* Amy feedback

* Update docs/advanced-features/middleware.md

Co-authored-by: Amy Burns <amy.burns@vercel.com>

* first commit

* more fixes

* re-structuring based on feedback

* changes to middleware.md

* updates to edge-api-routes

* code typo

* Update docs/advanced-features/middleware.md

Co-authored-by: JJ Kasper <jj@jjsweb.site>

* Update edge-api-routes.md

* Update Edge Runtime API docs

* Clarify API docs

* Update

* Update docs/advanced-features/middleware.md

* Update switchable runtime docs

* Update response

* experimental-edge

* Update docs/advanced-features/middleware.md

* Add example of forwarding headers and address comments

* Add proxying headers to middleware upgrade guide

* Apply suggestions from code review

Co-authored-by: Jeff Escalante <jescalan@users.noreply.github.com>

* fix middleware directory spec

* localization explanation

* update detecting runtime

* Update docs/advanced-features/react-18/switchable-runtime.md

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* fix prettier issues

* table fix

* Update docs/advanced-features/react-18/switchable-runtime.md

Co-authored-by: Jeff Escalante <jescalan@users.noreply.github.com>

* Update docs/api-routes/edge-api-routes.md

Co-authored-by: Jeff Escalante <jescalan@users.noreply.github.com>

* lint-fix

Co-authored-by: molebox <hello@richardhaines.dev>
Co-authored-by: Amy Burns <amy.burns@vercel.com>
Co-authored-by: Ismael Rumzan <ismael.rumzan@gmail.com>
Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
Co-authored-by: Jeff Escalante <jescalan@users.noreply.github.com>
Co-authored-by: Ismael <ismael@vercel.com>
2022-06-28 10:22:48 -05:00
Houssein Djirdeh
82dce6ce8e
[Script] Allow next/script to be placed in _document body (#37894)
Fixes https://github.com/vercel/next.js/issues/37741. Allows `next/script` to be placed inside of `_document` body in addition to `Head`.

## Bug

- [X] Related issues linked using `fixes #number`
- [X] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-06-27 17:56:53 +00:00
Steven
5ea3f6c4ab
Remove layout raw image experiment (#38006)
This PR removes experimental `layout="raw"` from `next/image` since it was moved to `next/future/image` in #37927
2022-06-27 15:11:15 +00:00
Jiachi Liu
a5f8382ee3
Rename page runtime edge to experimental-edge (#38041)
* Rename page runtime edge to experimental-edge

* fix ut

* fix lint

* PageRuntime -> ServerRuntime

* rename constant
2022-06-26 20:02:24 -05:00
Lee Robinson
dbfd594e8c
Add SWC plugins to version history in docs. (#38039) 2022-06-26 18:39:27 +00:00
Gal Schlezinger
22206651a6
[eslint-plugin-next] remove no-server-import-in-page rule (#38028)
This rule was good and kinda made sense when we had nested Middleware.
Now that we have a single Middleware, one might extract logic into different places
and I don't think we should limit importing `NextResponse` or `NextRequest`.

## Related

- Closes #36239
- Closes #37309



## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-06-26 12:43:15 +00:00
Mikis Woodwinter
2b451ee69a
feat(cli): allow configuration of http-server's timeout configuration (#35827)
* feat: add keep-alive timeout params for next-start

* feat: add keep-alive timeout args to next-cli's start

* docs: add docs for keep-alive timeouts

* docs: fix grammar & typos

* refactor: handle NaN for args

* test: add tests for timeout args

* revert: remove headersTimeout option

* fix: remove input validation for keepAliveTimeout arg

* feat: add input-range validation for keepAliveTimeout arg

* Error and tests for range validation

* Make sure timeout actually changes

* Fix error messsage

* Apply suggestions from code review

Co-authored-by: Steven <steven@ceriously.com>

Co-authored-by: Hannes Bornö <hannes.borno@vercel.com>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
Co-authored-by: Steven <steven@ceriously.com>
2022-06-26 13:26:51 +02:00
JJ Kasper
a148d1426d
Add note about skipping upstream cache during revalidation (#38014)
This adds a note about ensuring requests during a revalidation don't leverage an upstream cache as it will fail to pull fresh data to update the ISR cache with if configured. 

## Documentation / Examples

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

Fixes: https://github.com/vercel/next.js/issues/35523#issuecomment-1154687543
x-ref: https://github.com/vercel/next.js/issues/35195


Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2022-06-25 16:26:12 +00:00
Lee Robinson
8ce2790026
On-demand ISR updates. (#37955)
* On-demand ISR updates.

* Apply suggestions from code review

* lint-fix

* Update docs/basic-features/data-fetching/incremental-static-regeneration.md

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-24 16:59:23 -05:00
Lee Robinson
5646e43f83
Fix typo for rewrites to rewrite. (#38000) 2022-06-24 15:45:02 -05:00
JJ Kasper
20d6792542
Move outputStandalone config (#37994) 2022-06-24 14:58:35 -05:00
Steven
f8732d9cd7
Fix flaky onLoad() test for next/image/future (#37993)
This PR fixes flaky `onLoad()` test for `next/image/future`.

The test must modify the `src` after hydration to make sure it always works as expected.

This is because `next/image/future` uses native lazy loading and sometimes the event fires before hydration (docs were updated to mention this)
2022-06-24 19:28:48 +00:00
Balázs Orbán
90010be70d
docs: clarify NextRequest.ip (#37987)
Update server.md
2022-06-24 11:05:39 -05:00
Steven
e28d03c5a4
Add experimental next/future/image component (#37927)
This PR introduces a new experimental component, `next/future/image`, which is inspired by the existing experimental `layout="raw"`.

The difference is that much of the code has been deleted in order to reduce client-side code as well as reduce complexity:

- No `layout` prop
- No `loader` config (although `loader` prop works)
- No `IntersectionObserver`, use native `loading="lazy"` 
  - No `lazyBoundary`
  - No `lazyRoot`
- No `fill` (yet) so width & height are required
- No `objectFit` (use `style` instead)
- No `objectPosition` (use `style` instead)

This improves performance because native `loading="lazy"` doesn't need to wait for React Hydration and client-side JS.

In a future PR, we will modify `next/image` to remove `layout="raw"` since this new component supersedes it.

## Feature

- [x] Integration tests added
- [x] Documentation added
- [x] Telemetry added. In case of a feature if it's used or not.
- [x] Errors have helpful link attached, see `contributing.md`
2022-06-24 14:56:05 +00:00
JJ Kasper
7bb247ca8f
Move styled-jsx type reference (#37964)
Follow-up to https://github.com/vercel/next.js/pull/37902 this moves the reference to avoid a change in `next-env.d.ts`. Also updates our doc note on the `next-env.d.ts` file to be more explicit about it being ignored.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-23 19:26:08 +00:00
Leah
95449e6632
feat: enable styled-components css prop swc transform by default (#37962) 2022-06-23 18:08:22 +00:00
Leah
7c20918bc7
feat: enable configuration of styled-components transform and enable css prop support (#37861)
This allows configuring / overriding the default options of the `styled-components` swc transform and allows using the `css` prop support, which was already implemented, but not available.

Edit: made the CSS prop transform run before the display name, so it gets picked up by that and receives the (deterministic) name.

Relates to #30802
2022-06-23 16:55:05 +00:00
Raymond Cheng
ee89517848
Add a Plasmic example (#37522)
This adds a new example under `cms-plasmic/`. It serves as a general-purpose example that should be able to work with any Plasmic project, which can be set via environment variables.

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-22 15:19:04 +00:00
Rich Haines
cd2324c8b6
Adds new userAgent docs to the next/server docs page (#37613)
This PR adds a new section for the `userAgent` helper in `next/server`.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-22 15:07:24 +00:00
JJ Kasper
455d16419f
Fix some casing of "On-Demand ISR" (#37892) 2022-06-21 14:26:40 -05:00
Balázs Orbán
c04a6b04f2
chore(examples): fix active-class-name example (#37828)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-21 15:44:29 +00:00
Christian Nielsen
c8666a17eb
Fix typo in dynamic import section of dynamic-import.md (#37872)
Under the dynamic import section of dynamic-import.md, I've corrected "libaries" to "libraries".
2022-06-21 13:10:16 +00:00
Lee Robinson
8e28be0ad6
Update Middleware docs to mention canary version. (#37865) 2022-06-21 11:04:22 +02:00
Eric Burel
5035075556
Describe relation between region locale and country locale when a country is not found (#37745)
* Update i18n-routing.md

* lint-fix

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-20 10:29:58 -05:00
Yuddomack
e28e513616
fix: missing parentheses (#37839)
Hi~ I added the missing parentheses in document.

4ed0b78ab6/docs/advanced-features/middleware.md (L38-L40)


## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`


Co-authored-by: Balázs Orbán <18369201+balazsorban44@users.noreply.github.com>
2022-06-20 11:36:44 +00:00
Ekampreet Singh
3bf0fcf35d
fix typo in example section of dynamic-import.md (#37834)
change "in page's the" to "in the page's"
2022-06-20 11:00:52 +00:00
Simon Richard
06eb73b2d4
Update custom-document.md (#37811)
A small change, but eslint wasn't happy until I added this.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-06-18 22:27:29 +00:00
Steven
b7d057453d
Add images.unoptimized: true for easy next export (#37698)
In a previous PR (#19032), we added a hard error during `next export` if the default Image Optimization API is being used because it requires a server to optimized on demand. The error message offers several different solutions but it didn't consider that by the time someone runs `next export`, they are probably done writing their app.

So if `next export` is a hard requirement, the quickest path forward is to disable Image Optimization API. So this PR adds a new configuration option to `next.config.js`:

```js
module.exports = {
  images: {
    unoptimized: true
  }
}
```

### Update
Upon further discussion, we might want to avoid doing this just for images and instead introduce a top-level config to indicate export is coming and then handle errors or warn for [unsupported features](https://nextjs.org/docs/advanced-features/static-html-export#unsupported-features).

```
module.exports = {
  nextExport: true
}
```

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-06-16 20:20:17 +00:00
Hung Viet Nguyen
0f873c7eea
Update Jest config with SWC docs (#37705)
## Motivation/ Context
- When upgrading `next` from `11` to `12`, I followed [Upgrade guide from 11 => 12](https://nextjs.org/docs/upgrading#upgrading-from-11-to-12). I removed `.babelrc` to opt-in `SWC`. I thought that's all, but after removing `.babelrc`, Jest broke immediately. So I follow the guide https://nextjs.org/docs/advanced-features/compiler#jest to configure Jest to work with SWC. I copied the content of `jest.config.js` to my project but it does not work. The reason:
```diff
-const createJestConfig = nextJest({ dir }) // `dir` IS NOT DEFINED
+const createJestConfig = nextJest({ dir: './' }) // Should change to this. Sync with https://nextjs.org/docs/testing#setting-up-jest-with-the-rust-compiler
```
- This PR is to help others to configure Jest with SWC by copying code from the documentation site without encountering the same issue as I did.

## Documentation
- [x] Update the docs so users can just copy and paste when configuring Jest with SWC (Sync with https://nextjs.org/docs/testing#setting-up-jest-with-the-rust-compiler)
- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)

## Future work
- Since [Upgrade guide from 11 => 12](https://nextjs.org/docs/upgrading#upgrading-from-11-to-12) did not mention anything about Jest. If I remove `.babelrc` to opt-in SWC. The current Jest settings will crash (since it's using babel). We likely want to update the Upgrade guide to mention this cc: @leerob
2022-06-15 11:27:28 +00:00
Michael Novotny
5211ac5cae
Adds consistency to ESLint rules. (#34335)
* Adds consistency to ESLint rules.

* Fixes lint errors.

* Fixes manifest.

* Adds missing title.

* Fixes copy / paste error.

Co-authored-by: Lee Robinson <me@leerob.io>

* Update errors/no-script-in-document.md

Co-authored-by: Lee Robinson <me@leerob.io>

* Update errors/no-sync-scripts.md

Co-authored-by: Lee Robinson <me@leerob.io>

* Updates a couple of rule descriptions.

* Adds redirects.

* Fixes unit tests.

* Removes duplicated section.

* Updates `no-before-interactive-script-outside-document` description.

* Fixes lint.

* Fixes integration tests.

* Adds description to `no-before-interactive-script-outside-document` documentation.

* Removes `link-passhref` from rules list.

* Updates remaining `pages/_middleware.js` references.

* Adds consistancy to messaging in new `no-styled-jsx-in-document` rule.

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-13 21:17:42 -05:00
Steven
ec4df71352
Fix Image Optimization cache-control regression with external images (#37625)
In a previous PR (#34075), the ISR behavior was introduced to the Image Optimization API, however it changed the cache-control header to always set maxage=0. While this is probably the right behavior (the client shouldn't cache the image), it introduced a regression for users who have CDNs in front of a single Next.js instance (as opposed to [multiple Next.js instances](https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration#self-hosting-isr)).

Furthermore, the pros of client-side caching outweight the cons because its easy to change the image url (add querystring param for example) to invalidate the cache.

This PR reverts the cache-control behavior until we can come up with a better long-term solution.

- Fixes #35987
- Related to #19914 
- Related to #22319 
- Closes #35596
2022-06-13 22:13:55 +00:00
Hannes Bornö
7cc8f92241
i18n regression tests and docs for ignore locale in rewrite (#37581)
* Add regression tests for locale prefixed public files

* Add tests for ignoring source locale in rewrite

* Fix lint

* Add doc example

* Redirect tests

* fix test names

* update tests

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-10 14:04:31 -05:00
Lee Robinson
748c8e8002
Update deployment documentation. (#37571)
This PR adds new information to the Next.js deployment documentation to highlight examples or guides for deploying Next.js to a handful of services. This builds on the existing documentation around the Next.js Build API (from `next build`) and options for self-hosting with Node.js or Docker.

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-08 20:46:09 +00:00
Maedah Batool
f7ac942e6a
Add note about NEXT_DATA hydration (#37480)
Missing documentation around `NEXT_DATA` hydration when using `getServerSideProps()`. This PR warn users that the result of `getServerSideProps()/getStaticProps` is also available on the client-side due to React Hydration so they should not use any sensitive information in the props.



## Bug

- [x] Related issues linked using [fixes number](https://github.com/vercel/documentation/issues/418)
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

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


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-06-06 21:46:38 +00:00
Jiachi Liu
c984281f90
docs: fix usage in middleware errors (#37364)
## Documentation

- [x] Make sure the linting passes by running `pnpm lint`
2022-06-01 12:03:07 +00:00
Tuan Nguyen
b173abaf49
Add a note (#37315)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-05-31 02:28:06 +00:00
Lee Robinson
741626559d
Improve next/dynamic docs and add links to layouts RFC. (#37244)
- Updates `next/dynamic` docs to teach Suspense first
- Adds links to Layouts RFC in layouts/pages docs
- Clarifies and simplifies streaming docs

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-05-29 23:48:41 +00:00
Ryan
f4dcb81d61
[docs] Clarify "When does getStaticProps run" note (#37289)
Changed bullet points to say "getStaticPaths" instead of "getStaticProps".

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

## Feature

- [x] Related issues linked using `fixes #number`
- [x] Documentation added

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-05-29 22:17:29 +00:00
Donny/강동윤
748ce123b2
Add swcMinifyDebugOptions (#37172)
This also updates swc crates to 7eac561639

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-05-29 03:53:57 +00:00
Steven
57dcc9d329
Update pnpm create next-app for latest pnpm 6 and 7 (#37254)
This command changed in pnpm [6.32.13](https://github.com/pnpm/pnpm/releases/tag/v6.32.13) and [7.1.1](https://github.com/pnpm/pnpm/releases/tag/v7.1.1) so lets update it since its been a few weeks and we can expect pnpm users to update more regularly than npm users.

- Fixes https://github.com/vercel/next.js/pull/37240 
- Fixes https://github.com/vercel/next.js/pull/37045
- Fixes https://github.com/vercel/next.js/pull/37032
- Fixes https://github.com/vercel/next.js/pull/36602
- Fixes https://github.com/vercel/next.js/pull/36496
2022-05-27 21:21:40 +00:00
Tom
4f4c507064
add supported API's link to middleware docs (#37251)
Fixes #37064

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-05-27 18:36:14 +00:00
Lee Robinson
8aa15a21f8
Add note that next build output is compressed. (#37228)
When you run `next build`, the sizes you're seeing in the output are the compressed sizes with gzip.
2022-05-26 22:53:17 +00:00
OJ Kwon
fc61428db1
feat(next/swc): support experimental swc plugins (#36790)
* build(cargo): build swc with plugin support

* feat(next): expose experimental swcplugins config

* docs(compiler): add description

* build(cargo): resolve feature conflicts

* build(cargo): resolve build conflict

* Update docs/advanced-features/compiler.md

Co-authored-by: Maia Teegarden <dev@padmaia.rocks>

Co-authored-by: Maia Teegarden <dev@padmaia.rocks>
2022-05-26 15:16:26 -07:00
Stanley Hong
e4a9f09d45
Fix broken links in image.md (#37223)
**Broken** 
(#local-images)

**Updated**
(/docs/basic-features/image-optimization.md#local-images)
2022-05-26 18:10:12 +00:00
Naing
6736041d51
Update incremental-static-regeneration.md (#37159)
I couldn't understand well this sentence at the first time of reading as a non native english speaker. I think 'that' is needed here.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-05-24 14:27:17 +00:00
Ben Butterworth
f46bd5f829
Add section for jetbrains webstorm debugging (#24556)
* Add section for jetbrains webstorm debugging

I learnt of the solution [here](https://stackoverflow.com/questions/54354389/how-does-one-debug-nextjs-react-apps-with-webstorm) after spending more than a hour trying to find a solution. I think it would be a nice addition to the docs.

* update test

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-05-22 22:30:14 -05:00
Sharath Challa
11ad65e445
Add eslint rule for not allowing styled-jsx in _document.js (#32678)
## Bug

- [ ] Related issues linked
fixes #32656



Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-05-23 02:32:13 +00:00
Ignat Zapolsky
2f9e2415e5
Update testing.md (#29954)
I've improved jest configuration that :
1. Starts collecting test coverage
1. Does not collect coverage for derived files or coverage info itself
1. Uses coverage provider that is based on node itself.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-05-23 01:07:20 +00:00
Jim Fisher
82fb4b408f
Clarify conditions under which process.env expressions are inlined (#33212)
## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-05-22 23:00:13 +00:00
Maedah Batool
84cba20ae7
Add docs about locale (#33401)
Came across this [Slack thread](https://vercel.slack.com/archives/C02F56A54LU/p1642206518128400). Update the docs about adding `locale` string in `getStaticPaths` docs.

## Feature

- [ ] Related issues linked using #32772
- [x] Documentation added

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`

Closes: #32772


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-05-22 22:52:41 +00:00
Guilherme Prezzi
3bd42b4d0b
docs: Add pageExtensions usage note in API Routes (#35918)
In order to turn the API Routes docs more clear about the file extensions when using `pageExtensions`.
I know that it was already explained [here](https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions).

But just think about the DX: If a developer have a trouble with an API endpoint not working properly should it check it on custom-page-extensions page or api-routes page itself??

Related to https://github.com/vercel/next.js/issues/8178.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-05-22 17:46:00 +00:00
Balázs Orbán
2e1740bb69
docs: clarify environment variables behavior (#36620)
Based on https://github.com/vercel/next.js/issues/36551#issuecomment-1113457752 making the docs more clear which also aligns with the wording of Environment Variables in Middlerware: https://nextjs.org/docs/api-reference/next/server#how-do-i-access-environment-variables

See also: https://github.com/vercel/next.js/pull/20869#issuecomment-757799953

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-05-22 16:57:55 +00:00
idkwhojamesis
5b893663fd
Include router.asPath caveats in docs (#36876)
initial commit

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-05-21 21:45:47 -05:00
Naveen
4fa54ede83
typo: Change yarn into pnpm (#37092)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-05-21 10:02:50 +00:00
LongYinan
33c837b115
Stabilize SWC emotion transform plugin (#37058) 2022-05-21 04:09:30 +00:00
Jiachi Liu
d25e246b50
Keep custom app as non server component (#37044)
We added custom _app as server component support in #33149, but we found it's pretty confusing on usage like support it both server component pages and regular pages at the same time for having similar layout purpose.
When using the _app.server and _app at the same time, applying them into proper places become more confusing.
In that case, we decide to make _app.js can't be a server component, and you can still keep all the existing thing there. And also you don't need to think of the corresponding APIs of custom _app in RSC

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Docs updated
2022-05-20 18:07:20 +00:00
JJ Kasper
760750d851
Add note clarifying pnpm args handling (#37049)
## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`

x-ref: https://github.com/vercel/next.js/pull/37045
x-ref: https://github.com/vercel/next.js/pull/37032
x-ref: https://github.com/vercel/next.js/pull/36602
x-ref: https://github.com/vercel/next.js/pull/36496
2022-05-19 22:35:39 +00:00
Damien Simonin Feugas
bf089562c7
feat(middleware)!: forbids middleware response body (#36835)
_Hello Next.js team! First PR here, I hope I've followed the right practices._

### What's in there?

It has been decided to only support the following uses cases in Next.js' middleware:
- rewrite the URL (`x-middleware-rewrite` response header)
- redirect to another URL (`Location` response header)
- pass on to the next piece in the request pipeline (`x-middleware-next` response header)

1. during development, a warning on console tells developers when they are returning a response (either with `Response` or `NextResponse`).
2. at build time, this warning becomes an error.
3. at run time, returning a response body will trigger a 500 HTTP error with a JSON payload containing the detailed error.

All returned/thrown errors contain a link to the documentation.

This is a breaking feature compared to the _beta_ middleware implementation, and also removes `NextResponse.json()` which makes no sense any more.

### How to try it?
- runtime behavior: `HEADLESS=true yarn jest test/integration/middleware/core`
- build behavior : `yarn jest test/integration/middleware/build-errors`
- development behavior: `HEADLESS=true yarn jest test/development/middleware-warnings`

### Notes to reviewers

The limitation happens in next's web adapter. ~The initial implementation was to check `response.body` existence, but it turns out [`Response.redirect()`](https://github.com/vercel/next.js/blob/canary/packages/next/server/web/spec-compliant/response.ts#L42-L53) may set the response body (https://github.com/vercel/next.js/pull/31886). Hence why the proposed implementation specifically looks at response headers.~
`Response.redirect()` and `NextResponse.redirect()` do not need to include the final location in their body: it is handled by next server https://github.com/vercel/next.js/blob/canary/packages/next/server/next-server.ts#L1142

Because this is a breaking change, I had to adjust several tests cases, previously returning JSON/stream/text bodies. When relevant, these middlewares are returning data using response headers.

About DevEx: relying on AST analysis to detect forbidden use cases is not as good as running the code.
Such cases are easy to detect:
```js
new Response('a text value')
new Response(JSON.stringify({ /* whatever */ })
```
But these are false-positive cases:
```js
function returnNull() { return null }
new Response(returnNull())

function doesNothing() {}
new Response(doesNothing())
```
However, I see no good reasons to let users ship middleware such as the one above, hence why the build will fail, even if _technically speaking_, they are not setting the response body. 



## Feature

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [x] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-05-19 22:02:20 +00:00
Javi Velasco
f354f46b3f
Deprecate nested Middleware in favor of root middleware (#36772)
This PR deprecates declaring a middleware under `pages` in favour of the project root naming it after `middleware` instead of `_middleware`. This is in the context of having a simpler execution model for middleware and also ships some refactor work. There is a ton of a code to be simplified after this deprecation but I think it is best to do it progressively.

With this PR, when in development, we will **fail** whenever we find a nested middleware but we do **not** include it in the compiler so if the project is using it, it will no longer work. For production we will **fail** too so it will not be possible to build and deploy a deprecated middleware. The error points to a page that should also be reviewed as part of **documentation**.

Aside from the deprecation, this migrates all middleware tests to work with a single middleware. It also splits tests into multiple folders to make them easier to isolate and work with. Finally it ships some small code refactor and simplifications.
2022-05-19 15:46:21 +00:00
Steven
9f0024a5ee
Change experimental layout=raw to use native img lazy loading (#36985)
This PR changes the experimental `layout=raw` images to use the native lazy loading behavior (as opposed to the IntersectionObserver).

This will (eventually) lead to smaller client bundles and faster image loading since there is no JS needed to load the image.

However, we'll lose the `lazyRoot` and `lazyBoundary` behavior since those are specific to the IntersectionObserver implementation.
2022-05-18 21:05:15 +00:00
Gaspar Garcia Jr
c72d32d3b5
Clarify .env* environment variable priority (#36967)
Clarify that the environment variables are ordered in descending priority and that the existing system environment is not overridden.

fixes https://github.com/vercel/next.js/issues/36966

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-05-17 17:52:41 +00:00
Sidharth Rathi
7b83c19da5
Support graceful shutdowns (#36909)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] Related issues linked using [19693](https://github.com/vercel/next.js/discussions/19693)
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ x] Make sure the linting passes by running `yarn lint`


Closes #29959
2022-05-16 14:40:39 +00:00
You Nguyen
c667d2ba72
Update runtime-configuration.md (#36923)
If I understand correctly, a page that relies on `publicRuntimeConfig` must be server-side rendered, then that page need either `getInitalProps` or `getServerSideProps`, or the application has a Custom App with `getInitialProps` enabled.
2022-05-16 09:15:01 +00:00
Jiachi Liu
ed4d009841
Drop the unstable web vital hook and remove exports of flush effects (#36912)
* remove the experimental web vital hook api
* remove the exported flush effects api and only error on development, keep only usage to styled-jsx

for web vital hook API: The usage is not widly adopted since the existing exported vital api could do the same work. In the future we'll deprecate the `_app.server` in favor of `_app` in server component pages. so that this api won't be required.

for flush effects api: other css-in-js libs are not using the same approach like styled-jsx which holding a style registry and could flush it during streaming. emotion-js and styled-components are still relying on `Document.getInitialProps` atm and we have supported it in latest canary
2022-05-14 21:20:24 +00:00
Josh Goldberg
fa4ca66f20
Update no-floating-promises lint rule docs page (#36913)
Small docs fix. We've got a snazzy new website at typescript-eslint.io. Eventually the .md docs pages will serve just as partial docs sources, not the right URL to visit.
2022-05-14 14:04:11 +00:00
Sagnik Chatterjee
3674cadae5
docs: adding changes to setCookie example (#36870)
fixes #28453

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [X] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [X] Make sure the linting passes by running `yarn lint`
2022-05-13 14:24:44 +00:00
Hunter Tunnicliff
521f88e159
Move CI build cache instructions to Deployment docs (#35418)
This PR moves the instructions for configuring CI providers to preserve Next.js's build cache out of the _No Cache Detected_ error message and into ~the _Deployment_~ a new page within the _Advanced Features_ docs. 

This change is beneficial because it makes the CI configuration examples visible in the context of other helpful documentation for deploying Next.js.

👉 **Prior to this change, these CI configuration examples didn't show up in the Next.js docs.**

The relocated instructions are now linked on the _No Cache Detected_ error message page.

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`

Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Steven <steven@ceriously.com>
2022-05-13 09:56:47 -04:00
Jiachi Liu
b717b6eb1d
docs: add more details about nextRuntime in webpack config and runtime in next config (#36862)
## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-05-12 16:53:59 +00:00
Robert Keyser
66d98e2fc6
scss exects semicolon (#36779)
copy/pasting the SCSS example into VSCode results in linter warning. Fixed with semicolon on variable assignment. Added the second semicolon for consistency.



## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-05-12 16:29:01 +00:00
Rich Haines
6a00a1b464
Updated copy around enabling source maps (#36852)
This PR updates the copy in the source maps section of the docs to reflect the improvement made to webpack that generate source maps.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-05-12 11:45:23 +00:00
James Perkins
22c0b65eb5
Fixing Tina + Adding a demo URL (#35480)
## Documentation / Examples

- Updating Tina Demo URL
- Adding Tina to blog-starter example
- Adding Tina to Basic features section
- Updating Tina to actually work again
2022-05-10 17:52:54 +00:00
Kiko Beats
b78c28f7a0
feat: better cookies API for Edge Functions (#36478)
This PR introduces a more predictable API to manipulate cookies in an Edge Function context.

```js
const response = new NextResponse()

// set a cookie
response.cookies.set('foo, 'bar') // => set-cookie: 'foo=bar; Path=/'`

// set another cookie
response.cookies.set('fooz, 'barz') // => set-cookie: 'foo=bar; Path=/, fooz=barz; Path=/'`

// delete a cookie means mark it as expired
response.cookies.delete('foo') // => set-cookie: 'foo=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT, fooz=barz; Path=/'`

// clear all cookies means mark all of them as expired
response.cookies.clear() // => set-cookie: 'fooz=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT, foo=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT'`
``` 

This new cookies API uses [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) interface, and it's available for `NextRequest` and `NextResponse`.

Additionally, you can pass a specific cookies option as a third argument in `set` method:

```js
response.cookies.set('foo', 'bar', {
  path: '/',
  maxAge: 60 * 60 * 24 * 7,
  httpOnly: true,
  sameSite: 'strict',
  domain: 'example.com'
}
```

**Note**: `maxAge` it's in seconds rather than milliseconds.

Any cookie manipulation will be reflected over the `set-cookie` header, transparently.

closes #31719
2022-05-09 09:50:32 +00:00
Steven Tey
3fd1168504
Fixed typo (#36753)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-05-07 20:50:31 +00:00
Rich Haines
49910ea9ac
Updated the middleware api docs env section to remove dev and prod (#36739)
…rding due to customer confusion

This PR updates the middleware (edge functions) api docs environment section to remove the dev and prod wording due to customer confusion

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-05-07 00:24:39 +00:00
Steven
da8d1984d2
Add experimental wildcard remotePatterns config for upstream images (#36245)
## Description 
This PR implements a new configuration object in `next.config.js` called `experimental.images.remotePatterns`.

This will eventually deprecate `images.domains` because it covers the same use cases and more by allowing wildcard pattern matching on `hostname` and `pathname` and also allows restricting `protocol` and `port`.

## Feature

- [x] Implements an existing feature request.
- [x] Related issues linked
- [x] Unit tests added
- [x] Integration tests added
- [x] Documentation added
- [x] Telemetry added. In case of a feature if it's used or not.
- [x] Errors have helpful link attached, see `contributing.md`

## Related 

- Fixes #27925 
- Closes #18429 
- Closes #18632
- Closes #18730
- Closes #27345
2022-05-05 02:19:16 +00:00
Ryan Patterson
d1db7141ba
Add docs about nextRuntime for custom webpack (#36685)
This variable is exported by next but undocumented, and its usage is necessary to build auxiliary scripts for your server-side applications. See https://github.com/vercel/next.js/issues/36237#issuecomment-1117694528 for an example.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-05-04 19:14:06 +00:00
oof2win2
3e78f0cb5d
fix(docs): mention cookies in context (#36342)
Mention that the HTTP.IncomingMessage object is augmented by `cookies` in getServerSideProps

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-05-04 16:25:55 +00:00
Stig Kleppe-Jørgensen
9cda84b484
Improve wording (#36649)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Improve wording
- [ ] Make sure the linting passes by running `yarn lint`
2022-05-03 21:57:29 +00:00
jpveilleux
0234e6d553
Added type to Page Component for TypeScript (#36608)
* Added type to Page Component for TypeScript

Following this tutorial, I noticed that TS was complaining that "getLayout" did not exist on Page. That is normal since Page is typed as NextPage. I simply exported the new type we create in "_App.tsx" and used it as the return type for Page. This will probably help others seeing that red in their editors and perhaps being confused.

* Small linting change

* Apply suggestions from code review

* Update layouts.md

* lint fix

* update type

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-05-03 15:58:31 -05:00
abdallah akrab
3682534986
docs: add jest-environment-jsdom package for Jest configuration (#36632)
## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`

Jest 28 does not include jest-environment-jsdom by default.

following guide & running jest without jest-environment-jsdom causes the following  error:

<img width="1598" alt="image" src="https://user-images.githubusercontent.com/37980706/166319065-2bc29bb4-7d56-43e5-b85d-5a7484f17b1b.png">
2022-05-03 11:12:52 +00:00
Lee Robinson
d6cb99b37e
Add docs about SSR caching (yes, you can do this with Next.js) (#36588)
I've heard a lot of folks not realize this is possible 😄 Hopefully this helps.
2022-04-30 16:45:54 +00:00
Houssein Djirdeh
fd2ba11763
Adds inline script functionality to next/script for worker and beforeInteractive strategies (#36364)
Adds inline script functionality to `next/script` for `worker` and `beforeInteractive` strategies. 

- fixes #36318 
- fixes #26343
- fixes #26591
- fixes #26343
- fixes #26240


Co-authored-by: Janicklas Ralph <6142074+janicklas-ralph@users.noreply.github.com>
2022-04-29 15:20:31 +00:00
Adam Tolley
67a619ea64
Add note about running next without a sub-command (#36560)
This should be made explicitly clear because other code may just call `next` instead of `next dev` (e.g. https://github.com/netlify/framework-info/blob/main/src/frameworks/next.json).

Being in the ninth circle of debug hell right now I could not take it for granted that the two were the same till I saw some kind of confirmation, either from the docs or from the source.  Source is great, but calling it out in the docs would saved me some time.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-04-29 02:57:48 +00:00
Mohamed ElSaadany
e4f66fe911
Adds <link rel="preconnect" ... /> to example optimized font output (#36529)
This makes it clear that the font optimization adds these for you.
This avoids duplicate `<link rel="preconnect" />` in the HTML output if the developer is unaware that it is being added automatically.



## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-04-28 00:04:18 +00:00
Lee Robinson
ea0456dc07
Add docs on self-hosted ISR persisting across pods. (#36520)
ISR works self-hosted, but there's some more guidance needed when hosting with container-based setups (e.g. Kubernetes) and how the files are shared between different pods. This was based on community feedback. Please let me know if you'd like to see any additions here! 🙏
2022-04-27 23:38:08 +00:00
Alex Castle
93d8fac184
Always add height and width prop to image with layout="raw" (#36523)
This PR makes the following changes:
* Always add the `height` and `width` prop to image with `raw` layout (previously only added to images without `sizes`)
* Add a warning if a raw layout image is getting stretched (which can be caused by interaction of height and width prop with styles)
* Remove automatic aspect-ratio style from `raw` images. This is no longer necessary if all `raw` images have height and width props.
* Update tests and docs accordingly
2022-04-27 21:59:05 +00:00
Luis Alvarez D
ff140a7291
Update usage paragraph of next/script onLoad (#36453)
Changing the paragraph to not include `beforeInteractive` as one of the possible use cases of `onLoad`.

*Update:* Added docs for `onError` in the API reference of `next/script`.

@housseindjirdeh does `onError` also has the same limitation or is this only for `onLoad`?

Closes https://github.com/vercel/next.js/issues/33402

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-04-25 17:51:35 +00:00