Commit graph

949 commits

Author SHA1 Message Date
Jim Fisher
a2e65ac6d8
Docs: workarounds for router not resetting state (#35651)
* Docs: workarounds for router not resetting state (fixes #35138)

* Apply suggestions from code review

* updates

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-04-15 21:56:38 -05:00
Basant
ec7c911295
fixed typo, that should say 'in' not 'from' (#36046)
we can import server or client components in any server component, not from 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

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


Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-04-15 15:34:21 +00:00
Eric Burel
e69820accc
Loosen the "public" condition on getSSP (#36018)
<!--
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 `yarn lint`
** I've made the change via GitHub UI sorry :)**

Hi, 

I think the "data must be public" condition on getSSP is not really true, and even counter-productive. Being able to statically render more content is most probably positive, in terms of perceived and real performance of the app + energy consumption. It's actually totally possible, and not even that hard thanks to middleware, to statically render custom, paid, segment-specific content (and even individual-specific content under certain conditions).

I've documented the reason for this change in a few places if you want more details:
- related PR on React: https://github.com/reactjs/reactjs.org/pull/4566
- demo implementation and explanation on how to couple middlewares and getSSP to statically render any kind of content (including custom content): https://blog.vulcanjs.org/render-anything-statically-with-next-js-and-the-megaparam-4039e66ffde
2022-04-15 13:23:32 +00:00
Balázs Orbán
c0f979b5c8
Update upgrading.md (#36091) 2022-04-15 14:43:26 +02:00
Aman Mittal
4726b5a618
Add instructions to create pages directory and add an index.js file to it (#35971)
* Update from-create-react-app.md

* Update from-create-react-app.md

* Fix typo

* Update docs/migrating/from-create-react-app.md

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

* Update docs/migrating/from-create-react-app.md

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

* Update from-create-react-app.md

* fix lint-language issue

* Update .alexrc

* Update docs/migrating/from-create-react-app.md

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

* Update from-create-react-app.md

* Update docs/migrating/from-create-react-app.md

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

Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Steven <steven@ceriously.com>
2022-04-15 14:40:37 +02:00
Rich Haines
d38a46e2e4
Revert "Improvements to the MDX Docs and replaced a leftover reference to babel" (#36066)
Reverts vercel/next.js#35332
2022-04-11 16:11:35 +00:00
Amy Burns
9a7d175915
Moving middleware file (#36009)
This PR fixes a request from `@rauchg` that we specify more clearly that Middleware is Beta and organize it properly within the navigation. 

## 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-04-11 14:01:14 +00:00
Markos-Th09
5bf7265c35
Improvements to the MDX Docs and replaced a leftover reference to babel (#35332)
* Added next.config.mjs for @next/mdx

* Replaced leftover reference to babel

* Fixed formatting problem

* Added next-mdx-remote and @mdx-js/mdx as options
2022-04-11 12:21:43 +02:00
JJ Kasper
a0924fc7c7
Add docs for x-nextjs-cache header (#36023)
This adds documentation for the `x-nextjs-cache` header which is now exposed for ISR pages and image optimization requests to help signal the cache state. 

## Documentation / Examples

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

Co-authored-by: Steven <steven@ceriously.com>
2022-04-08 17:38:50 -04:00
Shu Ding
3d4f4c6995
Update the docs for Switchable Runtime (#36015)
As per the feedback in #35952.

## 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-08 16:26:14 +00:00
Björn
9c12d85c5d
Mention HTTP 303 See Other in redirects section (#35997)
Migrating from express to nextjs API routes broke one of our APIs because of how `redirect` works in nextjs vs. how it works in express. We need to redirect the user to a confirmation page via GET after making a POST request, which is not possible with `redirect`.

HTTP 303 seems to be the way to go in that case and I think it should be mentioned here.


## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-04-08 15:52:34 +00:00
Shu Ding
1c92591466
Update docs related to React 18 (#35952)
* update docs of streaming

* add switchable runtime docs

* add page to manifest

* Apply suggestions from code review

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

* Update docs/advanced-features/react-18/streaming.md

Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Steven <steven@ceriously.com>
2022-04-08 17:09:55 +02:00
Francis Gulotta
5feb400aff
docs: clarify when you use getServerSideProps (#35922)
Removed the misleading TTFB information. It was easy to read that incorrectly and while getStaticProps does have a better TTFB that's not why you might need to avoid getServerSideProps, I gave better examples. 

I also wanted to answer "well how do I cache `getServerSideProps`?" and now there's a link.

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-04-07 22:00:28 +00:00
Sølve Tornøe
07723be8b3
Refactor default locale prefix to support clone() (#35874)
## Bug
fixes https://github.com/vercel/next.js/issues/35273

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


## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-04-06 15:00:39 +00:00
白宦成
5a627019e9
fix: toBeInTheDocument is not a function (#35930)
fix when run jest with error "TypeError: expect(...).toBeInTheDocument is not a function"



![image](https://user-images.githubusercontent.com/13283837/161903133-501f6f6b-8623-4b1f-986f-0faa32b3ef91.png)

## Feature
- [x] Documentation added

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-04-06 13:13:45 +00:00
Aman Mittal
5429e8f12e
Update Manual Steps in Getting Started guide (#35898)
This PR add necessary information to the Manual Section to add directories such as `pages` and `public`.

## Bug

- [x] Related issues linked using fixes #29479 
- [ ] 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-06 13:06:50 +00:00
Lee Robinson
686a0f598a
Add Vitest example. (#35858)
## 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-04-04 18:25:56 +00:00
Lee Robinson
bcd2aa5c12
Link to with-docker-multi-env example. (#35820)
Based on feedback from Twitter to surface this more. A small improvement before improving the deployment docs further 😄
2022-04-01 15:45:22 +00:00
TianenPang
fbfe430cf0
Docs: update react 18's overview (#35766)
React 18 is now released and will have the following updates to the react 18 `overview` documentation

- Links
- Descriptions 
- Installation command
2022-03-31 07:46:06 +00:00
Steven
9f9214abe5
Updated create-next-app docs to include pnpm usage (#35755)
This PR updates the docs and examples for `create-next-app` to include pnpm usage.

The following script was used to update every example README:

```js
const fs = require('fs')
const examples = fs.readdirSync('./examples')

for (let example of examples) {
    const filename = `./examples/${example}/README.md`
    const markdown = fs.readFileSync(filename, 'utf8')
    const regex = new RegExp(`^yarn create next-app --example (.*)$`, 'gm')
    const output = markdown.replace(regex, (yarn, group) => {
        const pnpm = `pnpm create next-app -- --example ${group}`
        return `${yarn}\n# or\n${pnpm}`
    })
    fs.writeFileSync(filename, output)
}
```
2022-03-30 21:03:21 +00:00
VFLC
ced2040661
docs: fix typo in Script Component docs (#35731)
Added missing closing double quote : `strategy="worker` -> `strategy="worker"`



## 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-03-30 13:42:36 +00:00
Luis Alvarez D
ab119bcc79
Update middleware examples list (#35622)
Logging and analytics are not provided in vercel/examples using middleware.



## 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-03-28 16:05:58 +00:00
TianenPang
0d401ddcb5
Fix typo in rewrites docs (#35639)
Correct the type of `trailingSlash` in config example

Modified: `docs/api-reference/next.config.js/rewrites.md`

```diff
- trailingSlash: 'true',
+ trailingSlash: true,
```
2022-03-27 18:15:08 +00:00
Jiachi Liu
27d23f5b7b
docs: update styling support for streaming (#35375)
## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-03-26 20:19:21 +00:00
Jiachi Liu
d5e122594d
Update rsc refresh typing and doc example (#35543)
* Update rsc refresh typing and doc example

* Update docs/api-reference/next/streaming.md

Co-authored-by: Shu Ding <g@shud.in>

Co-authored-by: Shu Ding <g@shud.in>
2022-03-25 22:54:07 +01:00
hiro
f16ee05f59
Fix typo in docs (#35561)
The following files have been modified.

- `docs/api-reference/next.config.js/rewrites.md`
- `docs/basic-features/script.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-03-24 01:02:40 +00:00
JJ Kasper
432261a1e1
Add link for revalidate from notFound section (#35553) 2022-03-23 13:43:12 -05:00
Heyang Zhou
860c97ccf5
SWC import modularization plugin (#34969) 2022-03-22 14:20:57 +01:00
Luka Hartwig
af95b0cb8d
Server component docs use wrong next version (#35313)
The docs for the react server components preview refer refer to `next@latest` which doesn't work. The linked demo uses `canary` so I replaced it in the install command.
2022-03-21 23:54:43 +00:00
Thiago M
cd47984152
clarify use of Script (#35491)
Leave more clear that <Script> component can't be used inside Head. Current it says "without need", which don't implies it can't be used.



## 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-03-21 17:06:04 +00:00
Nelo
40a5c94ca7
Fix typo in getServerSideProps doc page (#35467)
While reading the documentation, I noticed that this paragraph was not correctly written and was hard to read. I fixed it adding a dot.

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-03-21 14:24:19 +00:00
Rich Haines
6f24c200db
Added note about why Next.js used 307 and 308 status codes (#35325)
This PR looks to clear up some confusion users are having around our decision to use 307 and 308 redirects, instead of 301 and 302

## 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 `yarn lint`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-03-19 16:49:24 +00:00
Steven
bc460229ab
Update next/image docs for width & height (#35188)
- Fixes #30219 

Co-authored-by: Rich Haines <hello@richardhaines.dev>
2022-03-17 15:16:15 -04:00
Lee Robinson
43941d2475
[docs] Update going to production docs around caching headers (#35374)
Follow up on https://github.com/vercel/next.js/pull/35336 based on suggestions I would have made pre-merge.
2022-03-16 22:11:06 +00:00
Antonio Young
86c1bf6d2b
[docs] Update docs about Cache-Control default headers. (#35336)
* Update docs about Cache-Control default headers.

* Update docs: Override the default in case of gSSP

* Apply suggestions from code review

* Update going-to-production.md

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-03-16 11:48:45 +01:00
Kyle Holmberg
ed1eedaa97
Encourage installation of sass as a devDep (#35323) 2022-03-15 15:42:36 +01:00
Aman Mittal
7891645d4b
Add info on context.ctx argument (#35303) 2022-03-15 15:34:49 +01:00
LongYinan
2e16d02faa
SWC emotion transform plugin (#34687) 2022-03-15 08:51:15 +01:00
Alex Castle
76bad07bdf
Add new 'raw' image layout (#34339)
This PR adds a new layout mode for images called `raw`, as discussed with the core team a while back. This mode has the following characteristics:
 - No wrapper `span` around the `img` element
 - No sizer svg
 - Almost no styles automatically added to the `img` element
 - `style` parameter is allowed and is passed through to the underlying `img` element

This also adds documentation changes to describe the new component.

There are a few tradeoffs and DX decisions that may warrant discussion/revision before merging. I'll add a few comments to highlight those issues.

- Related to #18637
2022-03-14 10:25:23 -04:00
Houssein Djirdeh
79016b879f
Adds web worker support to <Script /> using Partytown (#34244)
## Summary

This PR adds a new `worker` strategy to the `<Script />` component that automatically relocates and executes the script in a web worker.

```jsx
<Script 
  strategy="worker"
  ...
/>
```

[Partytown](https://partytown.builder.io/) is used under the hood to provide this functionality.

## Behavior

- This will land as an experimental feature and will only work behind an opt-in flag in `next.config.js`:

  ```js
  experimental: {
    nextScriptWorkers: true
  }
  ```

- This setup use a similar approach to how ESLint and Typescript is used in Next.js by showing an error to the user to install the dependency locally themselves if they've enabled the experimental `nextScriptWorkers` flag.

  <img width="1068" alt="Screen Shot 2022-03-03 at 2 33 13 PM" src="https://user-images.githubusercontent.com/12476932/156639227-42af5353-a2a6-4126-936e-269112809651.png">
- For Partytown to work, a number of static files must be served directly from the site (see [docs](https://partytown.builder.io/copy-library-files)). In this PR, these files are automatically copied to a `~partytown` directory in `.next/static` during `next build` and `next dev` if the `nextScriptWorkers` flag is set to true.

## Checklist

- [X] 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 `fixes #number`
- [X] Integration tests added
- [X] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.

This PR fixes #31517.
2022-03-11 22:26:46 +00:00
Steven
f8a2350157
Add next/image docs section for animated images (#35123)
- Related to #34807
2022-03-08 18:42:32 +00:00
Luis Alvarez D
4c6c4904d7
Update shallow routing caveat (#35052)
Minor change to improve caveat clarity of doing shallow routing

## Documentation / Examples

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


Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2022-03-07 23:29:07 +00:00
F. Hinkelmann
3dfb66fc19
Fix missing parenthesis for link in docs (#35090)
## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-03-06 16:57:44 +00:00
Balázs Orbán
62c33c1eb7
feat: support pnpm with create-next-app (#34947)
* feat: support `pnpm` with `create-next-app`

* test: add `--use-pnpm` tests

* docs: mention `--use-pnpm` flag in docs

* test: remove `only`

* Update test/integration/create-next-app/index.test.ts

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

* chore: add pnpm action setup to tests

* chore: use latest pnpm

* chore: debug

* chore: debug

* fix: fall back to `yarn` instead of `npm`

* test: run all tests

Co-authored-by: Steven <steven@ceriously.com>
2022-03-04 00:49:24 +01:00
Sigurd Spieckermann
721dc7bccd
Add missing closing parenthesis in docs (#34924)
A closing parenthesis was missing in the docs about static HTML export.
2022-03-01 16:48:08 +00:00
Alessandro
281ef22eba
Fix broken link in react-18 streaming docs. (#34884)
A link leads to a 404 page due to a missing  `/ `
2022-02-28 15:09:09 +00:00
Lee Robinson
175e081e86
Improve TypeScript documentation. (#34690)
- Moves example out of hidden dropdown at the top and features more prominently
- Adds a clone and deploy link for those looking to get started immediately
- Cross-posts ignoring TS errors docs over, because I've personally assumed it should be on this page and then ctrl+f found nothing
- Added version history to the top, based on contents of this file
- Remove custom app caveats from code snippet to improve copy-paste ability
2022-02-28 08:32:27 +00:00
JJ Kasper
0aba3072cc
Fix issues in getStaticPaths docs (#34840) 2022-02-25 20:36:05 -08:00
Andrew Hollenbach
0ec57da3a9
Update inlineCode reference (#34817)
Howdy!

MDX no longer has an `inlineCode` component in their MDXProvider ([source](https://mdxjs.com/table-of-components/)). They've migrated to a `pre` component for blocks of code and a `code` component for inline code snippets, so I've updated the example to reflect this.

I validated this locally with these example components:

```jsx
const Code = (props) => (
  <code>
    {props.children}
  </code>
);

const Pre = (props) => (
  <pre>
    {props.children}
  </pre>
);

const components = {
  pre: Pre,
  code: Code,
  ...
};
```

Applied to a test `mdx` file:

```md
This is an `inline` example.

~~~
<p>Test code</p>
~~~
```

Which generates the following html:

```html
<p>This is an <code>inline</code> example.</p>
<pre>
  <code>&lt;p&gt;Test code&lt;/p&gt;</code>
</pre>
```

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-02-25 18:41:05 +00:00
Aman Mittal
f32fd48ee7
Add Error Handling document (#34329)
* Add Error Handling document

* Update error-handling.md

* Add more services on client errors after Jeff's recommendation

* Update docs/advanced-features/error-handling.md

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

* Update docs/advanced-features/error-handling.md

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

* Update error-handling.md

* Add info about handling file not found error

* Add a screenshot of overlay when in development mode

Co-authored-by: Steven <steven@ceriously.com>
2022-02-25 11:34:00 -05:00