Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vercel/next.js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v12.0.8
Choose a base ref
...
head repository: vercel/next.js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v12.0.9
Choose a head ref
Loading
Showing 344 changed files with 13,679 additions and 3,197 deletions.
52 changes: 11 additions & 41 deletions .github/workflows/build_test_deploy.yml
Original file line number Diff line number Diff line change
@@ -347,35 +347,6 @@ jobs:
- run: xvfb-run node run-tests.js test/integration/with-electron/test/index.test.js
if: ${{needs.build.outputs.docsChange != 'docs only change'}}

testYarnPnP:
runs-on: ubuntu-latest
needs: [build, build-native-dev]
env:
NODE_OPTIONS: '--unhandled-rejections=strict'
YARN_COMPRESSION_LEVEL: '0'
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
with:
node-version: 14

- uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}-${{ github.run_attempt }}

- uses: actions/download-artifact@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
name: next-swc-dev-binary
path: packages/next-swc/native

- run: bash ./scripts/test-pnp.sh
if: ${{needs.build.outputs.docsChange != 'docs only change'}}

testsPass:
name: thank you, next
runs-on: ubuntu-latest
@@ -387,7 +358,6 @@ jobs:
checkPrecompiled,
testIntegration,
testUnit,
testYarnPnP,
testDev,
testProd,
]
@@ -691,7 +661,7 @@ jobs:
# since the repo's dependencies aren't installed we need
# to install napi globally
- run: npm i -g @napi-rs/cli@1.2.1
- run: npm i -g turbo@1.0.24
- run: npm i -g turbo@1.0.28

- name: Build
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
@@ -826,7 +796,7 @@ jobs:
# since the repo's dependencies aren't installed we need
# to install napi globally
- run: npm i -g @napi-rs/cli@1.2.1
- run: npm i -g turbo@1.0.24
- run: npm i -g turbo@1.0.28

- name: Install
uses: actions-rs/toolchain@v1
@@ -924,7 +894,7 @@ jobs:
# since the repo's dependencies aren't installed we need
# to install napi globally
- run: npm i -g @napi-rs/cli@1.2.1
- run: npm i -g turbo@1.0.24
- run: npm i -g turbo@1.0.28
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
@@ -972,7 +942,7 @@ jobs:
# since the repo's dependencies aren't installed we need
# to install napi globally
- run: npm i -g @napi-rs/cli@1.2.1
- run: npm i -g turbo@1.0.24
- run: npm i -g turbo@1.0.28
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
@@ -1045,7 +1015,7 @@ jobs:
- name: 'Build'
run: |
docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder sh -c "npm i -g @napi-rs/cli@1.2.1 && npm i -g turbo@1.0.24 && turbo run build-native --cache-dir=".turbo" -- --release --target x86_64-unknown-linux-musl"
docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder sh -c "npm i -g @napi-rs/cli@1.2.1 && npm i -g turbo@1.0.28 && turbo run build-native --cache-dir=".turbo" -- --release --target x86_64-unknown-linux-musl"
- name: Upload artifact
uses: actions/upload-artifact@v2
@@ -1073,7 +1043,7 @@ jobs:
# since the repo's dependencies aren't installed we need
# to install napi globally
- run: npm i -g @napi-rs/cli@1.2.1
- run: npm i -g turbo@1.0.24
- run: npm i -g turbo@1.0.28

- name: Install Rust
uses: actions-rs/toolchain@v1
@@ -1134,7 +1104,7 @@ jobs:
# since the repo's dependencies aren't installed we need
# to install napi globally
- run: npm i -g @napi-rs/cli@1.2.1
- run: npm i -g turbo@1.0.24
- run: npm i -g turbo@1.0.28
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
@@ -1195,7 +1165,7 @@ jobs:
# since the repo's dependencies aren't installed we need
# to install napi globally
- run: npm i -g @napi-rs/cli@1.2.1
- run: npm i -g turbo@1.0.24
- run: npm i -g turbo@1.0.28

- name: Install Rust
uses: actions-rs/toolchain@v1
@@ -1255,7 +1225,7 @@ jobs:
# since the repo's dependencies aren't installed we need
# to install napi globally
- run: npm i -g @napi-rs/cli@1.2.1
- run: npm i -g turbo@1.0.24
- run: npm i -g turbo@1.0.28

- name: Install Rust
uses: actions-rs/toolchain@v1
@@ -1315,7 +1285,7 @@ jobs:
override: true
target: wasm32-unknown-unknown

- run: npm i -g turbo@1.0.24
- run: npm i -g turbo@1.0.28

- name: Turbo cache
id: turbo-cache
@@ -1360,7 +1330,7 @@ jobs:
with:
node-version: 14

- run: npm i -g turbo@1.0.24
- run: npm i -g turbo@1.0.28

- name: Install Rust
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
2 changes: 1 addition & 1 deletion .github/workflows/pull_request_stats.yml
Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ jobs:
# since the repo's dependencies aren't installed we need
# to install napi globally
- run: npm i -g @napi-rs/cli@1.2.1
- run: npm i -g turbo@1.0.14
- run: npm i -g turbo@1.0.28

- name: Build
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
10 changes: 9 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
Visit https://vercel.com/security to view the disclosure policy.
# Reporting Security Issues

If you believe you have found a security vulnerability in Next.js, we encourage you to let us know right away.

We will investigate all legitimate reports and do our best to quickly fix the problem.

Email `security@vercel.com` to disclose any security vulnerabilities.

https://vercel.com/security
7 changes: 3 additions & 4 deletions contributing.md
Original file line number Diff line number Diff line change
@@ -6,10 +6,9 @@ examples](#adding-examples)** below.

## Developing

The development branch is `canary`, and this is the branch that all pull
requests should be made against. After publishing a stable release, the changes
in the `canary` branch are rebased into `master`. The changes on the `canary`
branch are published to the `@canary` dist-tag daily.
The development branch is `canary`. This is the branch that all pull
requests should be made against. The changes on the `canary`
branch are published to the `@canary` tag on npm regularly.

To develop locally:

56 changes: 56 additions & 0 deletions docs/advanced-features/compiler.md
Original file line number Diff line number Diff line change
@@ -94,6 +94,34 @@ const customJestConfig = {
module.exports = createJestConfig(customJestConfig)
```

### Remove React Properties

Allows to remove JSX properties. This is often used for testing. Similar to `babel-plugin-react-remove-properties`.

To remove properties matching the default regex `^data-test`:

```js
// next.config.js
module.exports = {
experimental: {
reactRemoveProperties: true,
},
}
```

To remove custom properties:

```js
// next.config.js
module.exports = {
experimental: {
// The regexes defined here are processed in Rust so the syntax is different from
// JavaScript `RegExp`s. See https://docs.rs/regex.
reactRemoveProperties: { properties: ['^data-custom$'] },
},
}
```

### Legacy Decorators

Next.js will automatically detect `experimentalDecorators` in `jsconfig.json` or `tsconfig.json` and apply that. This is commonly used with older versions of libraries like `mobx`.
@@ -110,6 +138,34 @@ First, update to the latest version of Next.js: `npm install next@latest`. Then,
}
```

### Remove Console

This transform allows for removing all `console.*` calls in application code (not `node_modules`). Similar to `babel-plugin-transform-remove-console`.

Remove all `console.*` calls:

```js
// next.config.js
module.exports = {
experimental: {
removeConsole: true,
},
}
```

Remove `console.*` output except `console.error`:

```js
// next.config.js
module.exports = {
experimental: {
removeConsole: {
exclude: ['error'],
},
},
}
```

### importSource

Next.js will automatically detect `jsxImportSource` in `jsconfig.json` or `tsconfig.json` and apply that. This is commonly used with libraries like Theme UI.
2 changes: 1 addition & 1 deletion docs/advanced-features/i18n-routing.md
Original file line number Diff line number Diff line change
@@ -313,7 +313,7 @@ For [Automatically Statically Optimized](/docs/advanced-features/automatic-stati

For example, if you have 50 locales configured with 10 non-dynamic pages using `getStaticProps`, this means `getStaticProps` will be called 500 times. 50 versions of the 10 pages will be generated during each build.

To decrease the build time of dynamic pages with `getStaticProps`, use a [`fallback` mode](https://nextjs.org/docs/basic-features/data-fetching#fallback-true). This allows you to return only the most popular paths and locales from `getStaticPaths` for prerendering during the build. Then, Next.js will build the remaining pages at runtime as they are requested.
To decrease the build time of dynamic pages with `getStaticProps`, use a [`fallback` mode](/docs/api-reference/data-fetching/get-static-paths#fallback-true). This allows you to return only the most popular paths and locales from `getStaticPaths` for prerendering during the build. Then, Next.js will build the remaining pages at runtime as they are requested.

### Automatically Statically Optimized Pages

4 changes: 2 additions & 2 deletions docs/advanced-features/security-headers.md
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ module.exports = {
return [
{
// Apply these headers to all routes in your application.
source: '/(.*)',
source: '/:path*',
headers: securityHeaders,
},
]
@@ -43,7 +43,7 @@ This header controls DNS prefetching, allowing browsers to proactively perform d

This header informs browsers it should only be accessed using HTTPS, instead of using HTTP. Using the configuration below, all present and future subdomains will use HTTPS for a `max-age` of 2 years. This blocks access to pages or subdomains that can only be served over HTTP.

If you're deploying to [Vercel](https://vercel.com/docs/edge-network/headers#strict-transport-security), this header is not necessary as it's automatically added to all deployments.
If you're deploying to [Vercel](https://vercel.com/docs/edge-network/headers#strict-transport-security), this header is not necessary as it's automatically added to all deployments unless you declare [`headers`](/docs/api-reference/next.config.js/headers.md) in your `next.config.js`.

```jsx
{
8 changes: 4 additions & 4 deletions docs/api-reference/data-fetching/get-server-side-props.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
description: API reference for `getServerSideProps`. Learn how to fetch data on each request with Next.js.
---

# `getServerSideProps`
# getServerSideProps

<details>
<summary><b>Version History</b></summary>
@@ -41,9 +41,9 @@ The `context` parameter is an object containing the following keys:
- `locales` contains all supported locales (if enabled).
- `defaultLocale` contains the configured default locale (if enabled).

## `getServerSideProps` return values
## getServerSideProps return values

The `getServerSideProps` function should return an object with the following **optional** properties:
The `getServerSideProps` function should return an object with **any one of the following** properties:

### `props`

@@ -102,7 +102,7 @@ export async function getServerSideProps(context) {
}
```

### `getServerSideProps` with TypeScript
### getServerSideProps with TypeScript

For TypeScript, you can use the `GetServerSideProps` type from `next`:

6 changes: 3 additions & 3 deletions docs/api-reference/data-fetching/get-static-paths.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
description: API reference for `getStaticPaths`. Learn how to fetch data and generate static pages with `getStaticPaths`.
---

# `getStaticPaths`
# getStaticPaths

<details>
<summary><b>Version History</b></summary>
@@ -27,7 +27,7 @@ export async function getStaticPaths() {
}
```

## `getStaticPaths` return values
## getStaticPaths return values

The `getStaticPaths` function should return an object with the following **required** properties:

@@ -199,7 +199,7 @@ export async function getStaticProps({ params }) {
export default Post
```

## `getStaticProps` with TypeScript
## getStaticPaths with TypeScript

For TypeScript, you can use the `GetStaticPaths` type from `next`:

8 changes: 4 additions & 4 deletions docs/api-reference/data-fetching/get-static-props.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
description: API reference for `getStaticProps`. Learn how to use `getStaticProps` to generate static pages with Next.js.
---

# `getStaticProps`
# getStaticProps

<details>
<summary><b>Version History</b></summary>
@@ -39,9 +39,9 @@ The `context` parameter is an object containing the following keys:
- `locales` contains all supported locales (if enabled).
- `defaultLocale` contains the configured default locale (if enabled).

## `getStaticProps` return values
## getStaticProps return values

The `getStaticProps` function should return an object with the following **optional** properties:
The `getStaticProps` function should return an object containing either `props`, `redirect`, or `notFound` followed by an **optional** `revalidate` property.

### `props`

@@ -192,7 +192,7 @@ export async function getStaticProps() {
export default Blog
```

## `getStaticProps` with TypeScript
## getStaticProps with TypeScript

You can use the `GetStaticProps` type from `next` to type the function:

Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ description: Configure the build id, which is used to identify the current build

# Configuring the Build ID

Next.js uses a constant id generated at build time to identify which version of your application is being served. This can cause problems in multi-server deployments when `next build` is ran on every server. In order to keep a static build id between builds you can provide your own build id.
Next.js uses a constant id generated at build time to identify which version of your application is being served. This can cause problems in multi-server deployments when `next build` is run on every server. In order to keep a consistent build id between builds you can provide your own build id.

Open `next.config.js` and add the `generateBuildId` function:

4 changes: 2 additions & 2 deletions docs/api-reference/next.config.js/headers.md
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ description: Add custom HTTP headers to your Next.js app.

</details>

Headers allow you to set custom HTTP headers for an incoming request path.
Headers allow you to set custom HTTP headers on the response to an incoming request on a given path.

To set custom HTTP headers you can use the `headers` key in `next.config.js`:

@@ -50,7 +50,7 @@ module.exports = {
`headers` is an async function that expects an array to be returned holding objects with `source` and `headers` properties:

- `source` is the incoming request path pattern.
- `headers` is an array of header objects with the `key` and `value` properties.
- `headers` is an array of response header objects, with `key` and `value` properties.
- `basePath`: `false` or `undefined` - if false the basePath won't be included when matching, can be used for external rewrites only.
- `locale`: `false` or `undefined` - whether the locale should not be included when matching.
- `has` is an array of [has objects](#header-cookie-and-query-matching) with the `type`, `key` and `value` properties.
2 changes: 0 additions & 2 deletions docs/api-reference/next.config.js/redirects.md
Original file line number Diff line number Diff line change
@@ -23,8 +23,6 @@ description: Add redirects to your Next.js app.

Redirects allow you to redirect an incoming request path to a different destination path.

Redirects are only available on the Node.js environment and do not affect client-side routing.

To use Redirects you can use the `redirects` key in `next.config.js`:

```js
Loading