Commit graph

686 commits

Author SHA1 Message Date
Scotty Waggoner
04cc37f763
Add docs for using pageExtensions to colocate other files with page components (#22740)
Feel free to edit this/suggest changes as you see fit to match the style of your docs or how you want this feature represented.

There seemed to be many issues regarding colocating non-page files with page components in  the `pages` directory where `pageExtensions` was finally suggested as a solution. I think it would be great to document it better since it seems to be a often requested workflow to colocate test, generated files, styles, and other files needed by page components in the `pages` directory. The note that exists in the docs currently alludes to the ability to do this but it doesn't contain much context that would help make it more discoverable.

Relevant issues:
https://github.com/vercel/next.js/discussions/11113#discussioncomment-427139
https://github.com/vercel/next.js/issues/8454#issuecomment-560432659
https://github.com/vercel/next.js/issues/8617#issuecomment-790030032
https://github.com/vercel/next.js/issues/3728#issuecomment-523789071
2021-08-27 22:58:56 +00:00
Delba de Oliveira
27c2937cc7
Update with-jest packages and docs (#28209)
This PR updates the with-jest example to the latest version of Jest and adds a note about the Jest and RTL testing environments (related to this [discussion](https://github.com/vercel/next.js/discussions/28337)). Also adds minor tweaks to the testing docs. 


## 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
2021-08-26 16:18:22 +00:00
Hunter Tunnicliff
877f982924
Use recommended pattern in testing example (#28404)
* Use recommended pattern in testing example

Since the official linter for testing library, `eslint-plugin-testing-library` recommends using `screen` to write queries, this MR updates the testing library example to follow the pattern recommended by the linter.

> DOM Testing Library (and other Testing Library frameworks built on top of it) exports a screen object which has every query (and a debug method). This works better with autocomplete and makes each test a little simpler to write and maintain.

> This rule aims to force writing tests using built-in queries directly from screen object rather than destructuring them from render result. Given the screen component does not expose utility methods such as rerender() or the container property, it is correct to use the render returned value in those scenarios.

See the `prefer-screen-queries` rules docs for more info: https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-screen-queries.md

* Update devDependencies

* Install and configure test linting

* Use recommended pattern in test

* Update test names for consistency

* Update docs

* Set jest environment in each file

* Use root true in `with-jest` eslint config

* Ensure nested .eslintrcs are not loaded for repo lint

Co-authored-by: jj@jjsweb.site <jj@jjsweb.site>
2021-08-25 12:33:57 -05:00
JJ Kasper
f21685549a
Update i18n locales limit to warning (#28429)
* Update i18n locales limit to warning

* update version -> versions

* bump

* Use Log.warn instead

* Apply suggestions from code review

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


Co-authored-by: Lee Robinson <me@leerob.io>
2021-08-25 08:54:38 -05:00
Steven
cb6290adf3
Update docs for sharp usage to mention Vercel (#28476)
There was some confusion in [this tweet](https://twitter.com/mtliendo/status/1430269174459338759) so I revised the docs around `sharp` usage.
2021-08-24 22:51:28 +00:00
Robbie Averill
57965770b9
Minor docs edit: cors -> CORS (#28472)
## Documentation / Examples

- [x] Make sure the linting passes
2021-08-24 17:23:40 +00:00
Houssein Djirdeh
80921b6a54
enables eslint caching by default (#28349)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-08-23 12:56:21 -05:00
Lee Robinson
8afa24fca5
Improved next/image docs around layouts. (#28345)
There's been community feedback the `layouts` section of `next/image` docs could be improved. Thanks to this great article (https://blog.eyas.sh/2021/08/gatsby-to-next-js/), I've added a helpful table here giving a high-level overview, as well as re-organized the `layout` section to be more helpful.
2021-08-23 17:39:19 +00:00
Kornel Dubieniecki
d143d9879f
docs: update font-optimization.md (#28397)
Adding display property to the examples as just copying them shows a 'Display parameter is missing.' warning.
Also added a link to the docs.

## Documentation / Examples

- [ ] Make sure the linting passes
2021-08-23 16:07:54 +00:00
Behzad Mehrabi
d6e82484f4
fix link to global stylesheet in from-create-react-app.md (#28327) 2021-08-20 12:18:27 +00:00
Aryan Beezadhur
864a1893c3
Update supported-browsers-features.md (#28326) 2021-08-20 11:52:20 +00:00
stefanprobst
da4203d032
Add eslint rule for id attribute on inline next/script (#27853)
This adds a new ESLint rule to `eslint-plugin-next` to check that `next/script` components with inline content have the required `id` attribute.

Also adjusted the code example for inline scripts in the `next/script` docs, which were actually missing an `id` attribute.
And also updated the `next/scripts` integration test to also have the required `id` attribute.

Unsure about the required heading levels in the errors .md document (other examples have h1 and h4??)

## 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.
- [x] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes
2021-08-19 20:08:04 +00:00
Brody McKee
0d3fb75cb6
Add docs for ESLint plugin settings and rule options (#28059)
This PR adds documentation for the new `rootDir` setting (#27918), and for `next/no-html-link-for-pages`.

## Documentation / Examples

- [x] Make sure the linting passes
2021-08-19 09:07:30 +00:00
Jiachi Liu
7ea7c23866
Document usage of suspense option of next/dynamic (#28210)
## Documentation / Examples

- [x] Make sure the linting passes
- [x] Errors have helpful link attached, see `contributing.md` (for #28165, #27611)
- [x] Update test case
2021-08-18 01:21:22 +00:00
Kevin Old
fe246bae36
docs: Add link to Cypress GitHub Actions Guide to Testing docs (#28207)
@leerob 

This pull request points to our [Cypress GitHub Actions Guide](https://on.cypress.io/github-actions) in the Cypress Documentation site.  It contains a guided walkthrough of using GitHub Actions with Cypress in text and our [recently released videos](https://on.cypress.io/ci-gha-playlist) in context. 

## Documentation / Examples

- [x] Make sure the linting passes
2021-08-17 17:55:24 +00:00
Urko Pineda
5d4d8802b8
Update testing.md (#28190)
Removed "`" with "'".



## 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
2021-08-17 14:06:21 +00:00
Rahul Gaba
da4d65252f
ESLint Plugin: Prefer next script component when using the inline script for Google Analytics. (#25147)
* Add a lint rule for using next script component when using inline script for Google Analytics.

* Apply suggestions from code review

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

* Update errors/next-script-for-ga.md

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

* Apply suggestions from code review

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-08-16 13:55:07 -05:00
Shun Tedokon
385ac94afd
docs: corrected the link to the example (#28175)
## Documentation

- Corrected the link in the **Next.js Testing Docs** to the correct one.
2021-08-16 17:15:21 +00:00
Oscar Fuentes
639b4d7d1f
doc: fix typo (#28146)
Given the context of the surrounding sentence, I believe the intention here was to use the word `increasing`. 



## 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
2021-08-16 02:51:06 +00:00
Lee Robinson
d5dc968134
Improve React Strict Mode documentation. (#28139)
The current text linked wasn't obvious. Plus, the best description of what Strict Mode is was at the bottom of the document.
2021-08-15 17:44:00 +00:00
Sam Poder
d57d9a5173
Add a Styling Section to next/image component docs (#28055)
## Feature

- [x] Documentation added

## Documentation / Examples

- [x] Make sure the linting passes

It seems that people currently struggle to style their image: https://twitter.com/achrlswrth/status/1425695122029744128, this clarifies that you can use className to do this (something I just learnt!). At the moment, this is kind of hidden in "other props" I think this makes it more clear for people

Thanks,

Sam
2021-08-14 03:56:33 +00:00
Gustav Pursche
22dbf275fe
Docs: Mention 3rd option 'blocking' for fallback (#28077)
* Docs: Mention 3rd option 'blocking' for fallback

* Update docs/basic-features/data-fetching.md

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-08-13 22:48:41 -05:00
Delba de Oliveira
04794776d8
[DOCS] Update testing docs (#28064)
This PR adds a recommendation to test production code with Cypress and re-orders the page information. 

## 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
2021-08-13 12:01:12 +00:00
Delba de Oliveira
40f85f6d95
[Docs] Add testing docs (#27965)
Add a new doc showing how to configure Jest and Cypress with Next.js

## 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
2021-08-11 20:47:12 +00:00
Sam Ko
b881d65c12
Adding a missing a period (#27928)
## 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 updated
- [ ] 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
2021-08-10 18:37:34 +00:00
ahmed osama
0cc4a98041
Little typo (#27911)
## 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
2021-08-10 12:01:14 +00:00
Nick Crews
0608f493dd
Document that Google has begun using CLS metric (#27843)
Google has begun using Cumulative Layout Shift as a factor in ranking search results, according to the linked Google docs.

This perhaps will make this page out of sync with other Nextjs docs, but I figure better start somewhere.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [x] 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
2021-08-08 17:52:44 +00:00
stefanprobst
62707d4590
fix eslint plugin install in docs (#27807) 2021-08-06 10:39:47 -05:00
Houssein Djirdeh
df83ccb7cd
[ESLint] Documentation updates + bug fixes (#26331)
Documentation:

- Expands the "Migrating Existing Config" section of ESLint doc to explain in more detail
- Minor changes to the "Ignoring ESLint" doc

Bug fixes:

- Adds `browser` and `node` environments to `eslint-config-next`. Closes #26319
- Fixes `no-document-import` rule. Closes #26159
- Fixes `no-page-custom-font` rule. Closes #26160 #26894
2021-08-05 00:58:06 +00:00
Houssein Djirdeh
7a1c9eb17e
[ESLint] Introduce a new setup process when next lint is run for the first time (#26584)
This PR introduces an improved developer experience when `next lint` is run for the first time.

### Current behavior

`eslint-config-next` is a required package that must be installed before proceeding with `next lint` or `next build`:

![image](https://user-images.githubusercontent.com/12476932/123468791-43088100-d5c0-11eb-9ad0-5beb80b6c968.png)

Although this has helped many developers start using the new ESLint config, this has also resulted in a few issues:

- Users are required to install the full config (`eslint-config-next`) even if they do not use it or use the Next.js plugin directly (`eslint-plugin-next`).
  - #26348

- There's some confusion  on why `eslint-config-next` needs to be installed or how it should be used instead of `eslint-plugin-next`.
  - #26574
  - #26475
  - #26438

### New behavior

Instead of enforcing `eslint-config-next` as a required package, this PR prompts the user by asking what config they would like to start. This happens when `next lint` is run for the first time **and** if no ESLint configuration is detected in the application.

<img src="https://user-images.githubusercontent.com/12476932/124331177-e1668a80-db5c-11eb-8915-38d3dc20f5d4.gif" width="800" />

- The CLI will take care of installing `eslint` or `eslint-config-next` if either is not already installed
- Users now have the option to choose between a strict configuration (`next/core-web-vitals`) or just the base configuration (`next`)
- For users that decide to create their own ESLint configuration, or already have an existing one, **installing `eslint-config-next` will not be a requirement for `next lint` or `next build` to run**. A warning message will just show if the Next.js ESLint plugin is not detected in an ESLint config. 

  <img width="682" alt="Screen Shot 2021-06-25 at 3 02 12 PM" src="https://user-images.githubusercontent.com/12476932/123473329-6cc4a680-d5c6-11eb-9a57-d5c0b89a2732.png">

---

In addition, this PR also:

- Fixes #26348
- Updates documentation to make it more clear what approach to take for new and existing ESLint configurations
2021-08-04 21:53:15 +00:00
Christian
d368f76b4d
Add a note about the existence of 'next/script' (#27725)
For users looking at the api reference for 'next/head' it might be a good idea to let them know that there is the 'next/script' component. Using 'next/script' has a lot of advantages over adding a script tag with 'next/head'

## Documentation / Examples

- [x] Make sure the linting passes
2021-08-03 21:07:58 +00:00
Steven
46e7658f7e
Add next.config.js option to override default keepAlive (#27709)
Follow up to #27376 so users can disable keep-alive.

See comment https://github.com/vercel/next.js/pull/27376#issuecomment-885415623
2021-08-03 00:38:42 +00:00
Steven
b05cdb1f64
Add naturalWidth/naturalHeight to onLoadingComplete() callback (#27695)
Resolves #27213
2021-08-02 23:14:38 +00:00
Lee Robinson
74503f1b8a
Improve custom server documentation. (#27693)
Based on feedback here https://github.com/vercel/next.js/discussions/27687#discussioncomment-1121013.
2021-08-02 16:17:27 +00:00
Zack Sheppard
807d1ec7ef
Clarify in docs that next/script must not be in next/head (#27534)
Documentation to help future developers avoid #27498 

## Documentation / Examples

- [X] Make sure the linting passes
2021-08-01 14:26:33 +00:00
JJ Kasper
c0bb1bc82c
Fix incorrect example in headers and rewrites docs (#27652)
x-ref: https://github.com/vercel/next.js/issues/22660#issuecomment-890400273

## Documentation / Examples

- [x] Make sure the linting passes
2021-07-31 21:53:47 +00:00
Sjors Smits
34d418c12d
[docs] Added per page layout example with TypeScript (#27488)
## Documentation / Examples

- [x] Make sure the linting passes

## Explanation
Fixes #27465 

I added some docs on how to use per page persistent layouts in TypeScript as this requires you to extend some types and it might not be trivial if you are just starting out with TypeScript.

I copied the js example so it might be better to remove some of the duplication where possible, let me know.
All feedback is welcome
2021-07-30 16:30:32 +00:00
JJ Kasper
1af78928d6
Document redirect query passing behavior (#27545)
This documents the request query passing behavior of redirects to help avoid confusion. 

## Documentation / Examples

- [x] Make sure the linting passes

Closes: https://github.com/vercel/next.js/issues/27194
2021-07-27 21:34:19 +00:00
Aryan Beezadhur
f3fcbef2cb
Update custom-page-extensions.md (#27541) 2021-07-27 20:15:50 +00:00
JJ Kasper
5eaca0ffe5
Document i18n locale limit (#27542)
Add check for i18n locale count and ensure the limit is documented

## Documentation / Examples

- [x] Make sure the linting passes
2021-07-27 20:09:36 +00:00
Asher Oloo
f22f88456d
Fixed minor grammar issue (#27493)
## 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
2021-07-26 04:19:37 +00:00
Michał Bundyra
7fe8a001e2
ESLint: custom directories from next.config.js (#26401)
Attempt to fix #26393

~~Sorry, I wasn't able to run tests on local, but I hope at least test should be valid.~~
Edit: Tests are working correctly on my local :) 

fixes #26393



## Bug

- [x] Related issues linked using `fixes #26393`
- [x] Integration tests added
2021-07-25 04:11:29 +00:00
kaykdm
3b2732bc36
[ESLint] add no-typos rule to eslint (#26650)
* add no-typos rule to eslint

* return early when function name is correct

* Handle null decl.type

* update check

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-24 22:22:19 -05:00
Arthur Puyou
fac083bcfa
Update max-age in HSTS sample (#27452)
The previous paragraph mentions a max-age of 2 years, so the number of seconds should match.
2021-07-23 18:01:36 -05:00
Steven
bf02cf84d9
Update next/image docs with onLoadingComplete() (#27440)
Follow up to #26824
2021-07-23 15:40:33 +00:00
Yubin
4e74db2d55
Add lazyBoundary prop to Image component (#27258)
This PR adds `lazyBoundary` prop on Image Component.
This feature is to load the images earlier.
I'm not good at English. So, I couldn't explain enough in the documentation what `lazyBoundary` is.

Feature request: https://github.com/vercel/next.js/discussions/24552

## 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.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes
2021-07-23 14:44:38 +00:00
Alex Castle
1b733423d6
Use Sharp if available for Image Optimization (#27346)
* Use sharp for image transformations when available

* Refactor resizeImage and add sharp warning

* only show sharp warning once per instance

* Modify sharp error message

* Add documentation for optional sharp dependency

* Update docs/basic-features/image-optimization.md

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

* Import types for sharp

* Update lockfile

* Add testing against sharp

* use fs-extra for node 12

* Rename test sharp path variable

* Apply suggestions from code review

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

* update squoosh specific test

* Apply suggestions from code review

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

* update tests

* Apply suggestions from code review

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

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-22 18:11:17 -05:00
Lee Robinson
14fb7df7f1
Clarify automatic updates in deployment. (#27418)
Slightly more clear 😄
2021-07-22 17:49:58 +00:00
Edward Brey
4c86976b36
Indicate attaching debugger (vs launching) (#27377)
The prior configuration name indicating that it launched the application. Really, it just attaches to an already running application, which the new name indicates.
2021-07-21 12:56:26 -05:00
Kyle Holmberg
7b0731af0c
Update docs around ISR revalidation (#25571)
* update docs around revalidation

* Apply suggestions from code review

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-20 15:11:46 -05:00
Isaac Abotsi
09baca03ad
docs: add note for Image responsive layout (#25915)
With the default Next.js template project, the .main and .container divs have `display: flex` style rule. However, as commented in [this issue](https://github.com/vercel/next.js/issues/18489#issuecomment-857146988), if may not display properly an <Image /> placed as direct child.



## Documentation / Examples

- [x] Make sure the linting passes
2021-07-20 20:05:56 +00:00
Sam Taal
a96739fc49
Add extra explanation to next/image about positioning (#27341)
* Add extra explanation to next/image about positioning

In my experience, when using next/image, a lot of devs forget about the `position: relative` when using `layout: fill`. I think it's a small and effective change to implement this one line to make it more clear.

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

* lint-fix

Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-20 10:30:08 -05:00
Steven
b123942694
Fix minimumCacheTTL so it doesn't affect browser caching (#27307)
In a previous PR (#27200), we added `minimumCacheTTL` to configure the time-to-live for the cached image. However, this was setting the `max-age` header.

This PR ensures that `minimumCacheTTL` doesn't affect browser caching, only the upstream header can affect browser caching.

This is a bit safer in case the developer accidentally caches something that shouldn't be and the cache needs to be invalidated. Simply delete the `.next/cache/images` directory.

- Related to #19914
- Related to #22319
2021-07-19 22:38:03 +00:00
Sam Robbins
187f4312cc
Use named functions in layouts docs (#27297)
## Documentation / Examples
- [x] Make sure the linting passes

Fixes #27252 by using a named function rather than an arrow function. If this is the correct fix, then modifications are also needed for the `layout-component` example, but I'm just providing this one modification right now in case this fix is incorrect.
2021-07-19 19:15:53 +00:00
Janicklas Ralph
dda23f5d9b
Fix inline scripts being duplicated when used with next/script component (#27218)
Fixes inline scripts being duplicated when used with `next/script` component

## Bug

- [x] fixes #26860 
- [x] Integration tests added


## Documentation / Examples
 Updated docs to indicate that `id` is needed for inline scripts
2021-07-16 18:58:34 +00:00
JJ Kasper
c7deb760b6
Document full routes order in rewrites doc (#27247)
This expands on https://github.com/vercel/next.js/pull/27211 and lists the full routes order used in Next.js to allow more exact matching when leveraging the different rewrite priorities. 

## Documentation / Examples

- [x] Make sure the linting passes
2021-07-16 18:03:50 +00:00
JJ Kasper
6e99f7af39
Add note about beforeFiles continuing (#27211)
This adds a note explaining that `beforeFiles` continue instead of checking the filesystem/dynamic routes immediately like they do in `afterFiles` and `fallback`. 

## Documentation / Examples

- [x] Make sure the linting passes

Closes: https://github.com/vercel/next.js/issues/26795
2021-07-16 16:13:40 +00:00
Remek Ambroziak
3fc5f73dc9
Fix typo in env howto (#27227) 2021-07-16 15:05:20 +00:00
Steven
8151a7e0dc
Add minimumCacheTTL config for Image Optimization (#27200)
- Closes #23328  
- Related to #19914 
- Related to #22319 


## Feature

- [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.
- [x] Errors have helpful link attached, see `contributing.md`
2021-07-15 19:55:12 +00:00
Tomas Jansson
d29a95ad63
Change pure functions to functions (#27192)
The right terminology should be used so we don't learn new developers wrong facts.

Using pure function here is plain wrong, the definition of a pure functions is as follows:

> The function return values are identical for identical arguments. The function application has no side effects. 

What you have here both have side effects, the calls to `res.setXXX`, and it isn't identical for identical arguments since you have `Date.now()`.



## 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
2021-07-15 14:12:58 +00:00
Steven
52a2022da4
Revert "Update data-fetching.md" (#27148)
Reverts vercel/next.js#27018 per comment https://github.com/vercel/next.js/pull/27018#issuecomment-877548891
2021-07-13 19:53:45 +00:00
Lee Robinson
1a9492d51f
Update Going to Production docs to use quote. (#27131)
Will make it look a little nicer 😄
2021-07-12 23:13:52 +00:00
Lee Robinson
a93f8b6393
Fix code block in Layouts docs. (#27130)
<img width="885" alt="CleanShot 2021-07-12 at 17 58 23@2x" src="https://user-images.githubusercontent.com/9113740/125365933-c2c17a00-e33a-11eb-9d24-5970b5437a21.png">
2021-07-12 23:04:06 +00:00
Steven
3b9786925d
Add jsdoc types to docs snippets (#27125)
This PR adds the JSDoc types so that VS Code and other tools can use autocompletion when editing `next.config.js`
2021-07-12 20:57:38 +00:00
Lee Robinson
26f4794944
[docs] Layouts & Going to Production (#27021)
- Helps clear up customer confusion about how to share React state with layouts, including nested layouts
- Provides guidance on best practices before shipping your application to production

Open to any feedback!
2021-07-12 19:04:43 +00:00
Tim Neutkens
5520dd3fd9
Mention customization of next.config.js to import images (#27104)
Fixes #27094



## 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
2021-07-12 13:16:13 +00:00
Karl Sander
13a4d29bf1
Docs/Typo: Replace triple dot character with real dots (#27030)
This was probably automatically inserted without the original author noticing. It causes some headache when copy&pasting the filename.
2021-07-08 21:52:59 +00:00
Steven
1a8ad14089
Rename next/image dangerously-unoptimized to custom and warn when applicable (#26998)
Since we are no longer accepting new built-in loaders, users may wish to use a different cloud provider.

So this PR renames `dangerously-unoptimized` to `custom` to handle this case as well as the intention of `next export`.

If the user doesn't add a `loader` prop, we throw an error.
If the user adds a `loader` prop but it doesn't return the width, we print a warning.

- Follow up to #26847 
- Fixes #21079 
- Fixes #19612 
- Related to #26850
2021-07-08 19:35:19 +00:00
Jaime Rios
1c2b171322
Update data-fetching.md (#27018)
Improve typing for use with Typescript example

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

## 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
2021-07-08 17:50:06 +00:00
Darsh Patel
226e81c733
Add dangerously-unoptimized loader for next/image (#26847)
* add support for static loader

* update existing test

* add test

* add prettier-ignore

* update docs

* apply suggestions from review

* remove un-needed normalize

* Apply suggestions from code review

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

* update test

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Steven <steven@ceriously.com>
2021-07-07 15:20:16 -05:00
Lee Robinson
c139f2566a
Reorder docs manifest and rename to Script Optimization. (#26874)
So there's _conformance_ between the other docs / optimizations.
2021-07-02 15:33:46 +00:00
Paul van den Dool
9039afe75b
Update to environment-variable.md (#26863)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added

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

## Documentation / Examples

- [ ] Make sure the linting passes

## Why the change
I lost quite a few hours figuring out why my environment variable was `undefined` in the browser.
I read about the built-in support and was like: "Oh nice" and didn't read much further. I missed the part about how you need to prefix your variables with `NEXT_PUBLIC_` in order to expose them to the browser.
I think a hint to this in the anchor link to that section will make it more discoverable as it's then mentioned near the top and will save people who are like me some time and a headache.
2021-07-02 10:35:53 +00:00
Steven
93f625428b
Add onLoadingComplete() prop to Image component (#26824)
This adds a new prop, `onLoadingComplete()`, to handle the most common use case of `ref`.

I also added docs and a warning when using `ref` so we recommend the new prop instead.
 
- Fixes #18398 
- Fixes #22482
2021-07-01 18:51:20 +00:00
Tim Neutkens
5b9ad8da90
Move next-server directory files to server directory (#26756)
* Move next-server directory files to server directory

* Update tests

* Update paths in other places
2021-06-30 13:44:40 +02:00
Lee Robinson
e8a9bd1996
Update next/image docs for relative parent with layout=fill. (#26615)
https://github.com/vercel/next.js/discussions/18739#discussioncomment-435925
2021-06-25 18:50:10 +00:00
Peter Mekhaeil
22d1771c29
Enable Alex documentation linting for docs (#26598) 2021-06-25 11:40:50 -05:00
Jiachi Liu
650ebed77e
doc: prettify docs for next script (#26572)
x-ref: https://github.com/vercel/next.js/pull/26518#issuecomment-867566010

## Documentation / Examples

- [x] Make sure the linting passes
2021-06-24 13:41:55 +00:00
Joshua Byrd
2c3624269a
Update SWR example to include fetcher function. (#26520)
* Previous example doesn't work

* Apply suggestions from code review

* Update docs/basic-features/data-fetching.md

* lint-fix

Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-06-23 23:41:15 -05:00
JJ Kasper
1012630bad
Add note about adding additional types (#26545)
* Add note about adding additional types

* Update to bold edit also

* Apply suggestions from code review

Co-authored-by: Steven <steven@ceriously.com>
2021-06-23 15:06:25 -05:00
JJ Kasper
1dd9c4b8d9
Update next-env note in docs (#26536)
This ensures we don't recommend editing the `next-env` file since we need to be able to tweak it to accept future types we add in Next.js


## Documentation / Examples

- [x] Make sure the linting passes

Closes: https://github.com/vercel/next.js/issues/26533
2021-06-23 16:20:28 +00:00
Vitaly Baev
cb95c59ad5
docs: updated minimum Node.js version (#26528)
## Documentation / Examples

- [x] Make sure the linting passes


According to new requirements in `package.json` minimum Node.js version for now is 12.0
2021-06-23 16:05:25 +00:00
JJ Kasper
c9119f845c
Update i18n fields in docs (#26492)
Closes: https://github.com/vercel/next.js/issues/24991

## Documentation / Examples

- [x] Make sure the linting passes
2021-06-22 17:52:26 +00:00
Sam Robbins
fc67fc737c
Add module.exports to security headers documentation (#26466)
Without `module.exports`, the provided code won't work if just pasted into `next.config.js`

## Documentation / Examples

- [x] Make sure the linting passes
2021-06-22 08:54:53 +00:00
JJ Kasper
2b761a9e47
docs(router.md) Add note about page state and navigation (#26320)
This adds a note to the router doc explaining that page state is not reset by default when updating the URL but staying on the same page as this has come up in a few issues. 


## Documentation / Examples

- [x] Make sure the linting passes

x-ref: https://github.com/vercel/next.js/issues/26270
2021-06-21 09:09:50 +00:00
Guilherme Araújo
2a5db0b58c
Docs: Add Prettier section on ESLint page (#26347)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added

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

## Documentation / Examples

- [x] Make sure the linting passes
2021-06-20 21:00:57 +00:00
Akash Patel
d88f484e89
add missing closing bracket (#26375)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added

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

## Documentation / Examples

- [ ] Make sure the linting passes
2021-06-20 17:30:09 +00:00
Lee Robinson
afa86cc5bb
Improve the next/script documentation. (#26325)
* Improve the `next/script` documentation.

* lint-fix

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-06-18 15:36:51 -05:00
Lee Robinson
ffaa4813b6
Add docs on adding HTTP security headers. (#25833) 2021-06-18 12:34:32 -05:00
Joe Bell
98acfaf8cc
Extend disclaimer for dynamic image imports (#26241)
* docs: extend disclaimer for dynamic image imports

* docs: extend guidance on blurDataURL

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

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2021-06-18 16:21:12 +02:00
Luke Ingalls
67f5830acc
docs: fixed typo (#26311) 2021-06-18 15:20:37 +02:00
neb
8a76cad98f
Fix closing tag in Script docs (#26276)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added

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

## Documentation / Examples

- [ ] Make sure the linting passes
2021-06-17 18:13:21 +00:00
Michael McQuade
2a9e29f635
Correct Next.js 9 upgrade instructions (#26271)
The upgrade instructions from version 9 to version 10 still had the `@latest` tag. This PR changes it to use `@10`
2021-06-17 17:35:12 +00:00
Choi Sumin
ab4ac8ad5c
docs: remove duplicated --ts, --typescript from Options (#26252)
## Documentation / Examples
https://nextjs.org/docs/api-reference/create-next-app#options
In Options, `--ts, --typescript` is duplicated! so i removed it 😃

- [x] Make sure the linting passes
2021-06-17 17:28:58 +00:00
Tim Neutkens
72743bcea8
Update next/script docs to clear up confusion around next/head and client-side JS (#26253) 2021-06-17 15:46:55 +02:00
Tim Neutkens
947ee9dd93
Update note in script doc (#26214) 2021-06-16 21:14:46 +02:00
Tim Neutkens
2967fe1df3
Update docs on static image imports (#26211)
Incorporates some of the feedback we've had about this doc.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added

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

## Documentation / Examples

- [ ] Make sure the linting passes
2021-06-16 18:46:01 +00:00
Steven
a3c31b6773
Update next/image docs and example with shimmer animation (#26183)
It was mentioned in Issue #18858 that we might add a `placeholder="skeleton"` but that didn't ship with Next.js 11 because it would likely need to handle additional config such as light mode / dark mode, speed, duration, etc.

So this PR adds an example of `blurDataURL` usage with a nice shimmer animation (sometimes called a skeleton).
2021-06-16 14:54:25 +00:00
Steven
4c5e9eb26a
Fix next/image docs version history (#26192)
Fixes version history in the `next/image` component [docs](
https://nextjs.org/docs/api-reference/next/image).

- [before.png](https://user-images.githubusercontent.com/229881/122237698-8874d200-ce8d-11eb-8b6b-6dad8ebfd13b.png)
- [after.png](https://user-images.githubusercontent.com/229881/122237708-8ad72c00-ce8d-11eb-891b-31f87847113c.png)
2021-06-16 14:48:42 +00:00
Wiktoria Mielcarek
7c8b504252
add missing step of installing next@latest (#26141)
- Step for installing the latest next version was missing
- Turned "Upgrade React version to latest" to an h3 heading



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added

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

## Documentation / Examples

- [ ] Make sure the linting passes
2021-06-16 11:42:12 +00:00
Lachlan Campbell
5ec2f981bc
docs(next/script): Improve formatting of docs (#26149)
Noticed a few things off in the Script docs—for example, the "before" variant should show using a non-React Component `<script>` tag, & the capitalization was inconsistent in a few places.

## Documentation / Examples

- [x] Make sure the linting passes
2021-06-16 07:07:56 +00:00