Skip to content

Commit

Permalink
Merge branch 'canary' into revert-33699-revert-33240-relay-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Jan 27, 2022
2 parents 7b337f3 + 7b524c1 commit b950d7e
Show file tree
Hide file tree
Showing 58 changed files with 461 additions and 218 deletions.
6 changes: 0 additions & 6 deletions .github/lock.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/lock.yml
@@ -0,0 +1,25 @@
name: 'Lock Threads'

on:
schedule:
# This runs every hour: https://crontab.guru/every-1-hour
- cron: '0 * * * *'
workflow_dispatch:

permissions:
issues: write
pull-requests: write

concurrency:
group: lock

jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v3
with:
github-token: ${{ secrets.LOCK_TOKEN }}
issue-inactive-days: 30
issue-comment: 'This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.'
pr-inactive-days: 30
5 changes: 4 additions & 1 deletion .github/workflows/stale.yml
Expand Up @@ -2,7 +2,8 @@ name: 'Stale issue handler'
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
# This runs every day 20 minutes before midnight: https://crontab.guru/#40_23_*_*_*
- cron: '40 23 * * *'

jobs:
stale:
Expand All @@ -12,10 +13,12 @@ jobs:
id: stale
name: 'Close stale issues with no reproduction'
with:
repo-token: ${{ secrets.STALE_TOKEN }}
only-labels: 'please add a complete reproduction'
close-issue-message: 'This issue has been automatically closed after 30 days of inactivity with no reproduction. If you are running into a similar issue, please open a new issue with a reproduction. Thank you.'
days-before-issue-close: 1
days-before-issue-stale: 30
days-before-pr-close: -1
days-before-pr-stale: -1
exempt-issue-labels: 'blocked,must,should,keep'
operation-per-run: 300 # 1 operation per 100 issues, the rest is to label/comment/close
4 changes: 2 additions & 2 deletions docs/advanced-features/custom-app.md
Expand Up @@ -38,14 +38,14 @@ export default MyApp

The `Component` prop is the active `page`, so whenever you navigate between routes, `Component` will change to the new `page`. Therefore, any props you send to `Component` will be received by the `page`.

`pageProps` is an object with the initial props that were preloaded for your page by one of our [data fetching methods](/docs/basic-features/data-fetching/index.md), otherwise it's an empty object.
`pageProps` is an object with the initial props that were preloaded for your page by one of our [data fetching methods](/docs/basic-features/data-fetching/overview.md), otherwise it's an empty object.

### Caveats

- If your app is running and you added a custom `App`, you'll need to restart the development server. Only required if `pages/_app.js` didn't exist before.
- Adding a custom [`getInitialProps`](/docs/api-reference/data-fetching/get-initial-props.md) in your `App` will disable [Automatic Static Optimization](/docs/advanced-features/automatic-static-optimization.md) in pages without [Static Generation](/docs/basic-features/data-fetching/get-static-props.md).
- When you add `getInitialProps` in your custom app, you must `import App from "next/app"`, call `App.getInitialProps(appContext)` inside `getInitialProps` and merge the returned object into the return value.
- `App` currently does not support Next.js [Data Fetching methods](/docs/basic-features/data-fetching/index.md) like [`getStaticProps`](/docs/basic-features/data-fetching/get-static-props.md) or [`getServerSideProps`](/docs/basic-features/data-fetching/get-server-side-props.md).
- `App` currently does not support Next.js [Data Fetching methods](/docs/basic-features/data-fetching/overview.md) like [`getStaticProps`](/docs/basic-features/data-fetching/get-static-props.md) or [`getServerSideProps`](/docs/basic-features/data-fetching/get-server-side-props.md).

### TypeScript

Expand Down
2 changes: 1 addition & 1 deletion docs/advanced-features/custom-document.md
Expand Up @@ -54,7 +54,7 @@ The `ctx` object is equivalent to the one received in [`getInitialProps`](/docs/
- `Document` is only rendered in the server, event handlers like `onClick` won't work.
- React components outside of `<Main />` will not be initialized by the browser. Do _not_ add application logic here or custom CSS (like `styled-jsx`). If you need shared components in all your pages (like a menu or a toolbar), take a look at the [`App`](/docs/advanced-features/custom-app.md) component instead.
- `Document`'s `getInitialProps` function is not called during client-side transitions, nor when a page is [statically optimized](/docs/advanced-features/automatic-static-optimization.md).
- `Document` currently does not support Next.js [Data Fetching methods](/docs/basic-features/data-fetching/index.md) like [`getStaticProps`](/docs/basic-features/data-fetching/get-static-props.md) or [`getServerSideProps`](/docs/basic-features/data-fetching/get-server-side-props.md).
- `Document` currently does not support Next.js [Data Fetching methods](/docs/basic-features/data-fetching/overview.md) like [`getStaticProps`](/docs/basic-features/data-fetching/get-static-props.md) or [`getServerSideProps`](/docs/basic-features/data-fetching/get-server-side-props.md).

## Customizing `renderPage`

Expand Down
4 changes: 2 additions & 2 deletions docs/advanced-features/preview-mode.md
Expand Up @@ -27,7 +27,7 @@ description: Next.js has the preview mode for statically generated pages. You ca
</ul>
</details>

In the [Pages documentation](/docs/basic-features/pages.md) and the [Data Fetching documentation](/docs/basic-features/data-fetching/index.md), we talked about how to pre-render a page at build time (**Static Generation**) using `getStaticProps` and `getStaticPaths`.
In the [Pages documentation](/docs/basic-features/pages.md) and the [Data Fetching documentation](/docs/basic-features/data-fetching/overview.md), we talked about how to pre-render a page at build time (**Static Generation**) using `getStaticProps` and `getStaticPaths`.

Static Generation is useful when your pages fetch data from a headless CMS. However, it’s not ideal when you’re writing a draft on your headless CMS and want to **preview** the draft immediately on your page. You’d want Next.js to render these pages at **request time** instead of build time and fetch the draft content instead of the published content. You’d want Next.js to bypass Static Generation only for this specific case.

Expand Down Expand Up @@ -230,7 +230,7 @@ This ensures that the bypass cookie can’t be guessed.
The following pages might also be useful.

<div class="card">
<a href="/docs/basic-features/data-fetching/index.md">
<a href="/docs/basic-features/data-fetching/overview.md">
<b>Data Fetching:</b>
<small>Learn more about data fetching in Next.js.</small>
</a>
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced-features/security-headers.md
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/data-fetching/get-initial-props.md
Expand Up @@ -119,7 +119,7 @@ export default class Page extends React.Component<Props> {
For more information on what to do next, we recommend the following sections:

<div class="card">
<a href="/docs/basic-features/data-fetching/index.md">
<a href="/docs/basic-features/data-fetching/overview.md">
<b>Data Fetching:</b>
<small>Learn more about data fetching in Next.js.</small>
</a>
Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/data-fetching/get-server-side-props.md
Expand Up @@ -144,7 +144,7 @@ export default Page
For more information on what to do next, we recommend the following sections:

<div class="card">
<a href="/docs/basic-features/data-fetching/index.md">
<a href="/docs/basic-features/data-fetching/overview.md">
<b>Data Fetching:</b>
<small>Learn more about data fetching in Next.js.</small>
</a>
Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/data-fetching/get-static-props.md
Expand Up @@ -237,7 +237,7 @@ export default Blog
For more information on what to do next, we recommend the following sections:

<div class="card">
<a href="/docs/basic-features/data-fetching/index.md">
<a href="/docs/basic-features/data-fetching/overview.md">
<b>Data Fetching:</b>
<small>Learn more about data fetching in Next.js.</small>
</a>
Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/next/router.md
Expand Up @@ -42,7 +42,7 @@ export default ActiveLink
The following is the definition of the `router` object returned by both [`useRouter`](#useRouter) and [`withRouter`](#withRouter):

- `pathname`: `String` - Current route. That is the path of the page in `/pages`, the configured `basePath` or `locale` is not included.
- `query`: `Object` - The query string parsed to an object. It will be an empty object during prerendering if the page doesn't have [data fetching requirements](/docs/basic-features/data-fetching/index.md). Defaults to `{}`
- `query`: `Object` - The query string parsed to an object. It will be an empty object during prerendering if the page doesn't have [data fetching requirements](/docs/basic-features/data-fetching/overview.md). Defaults to `{}`
- `asPath`: `String` - The path (including the query) shown in the browser without the configured `basePath` or `locale`.
- `isFallback`: `boolean` - Whether the current page is in [fallback mode](/docs/api-reference/data-fetching/get-static-paths.md#fallback-pages).
- `basePath`: `String` - The active [basePath](/docs/api-reference/next.config.js/basepath.md) (if enabled).
Expand Down
4 changes: 2 additions & 2 deletions docs/authentication.md
Expand Up @@ -8,7 +8,7 @@ Authentication verifies who a user is, while authorization controls what a user

## Authentication Patterns

The first step to identifying which authentication pattern you need is understanding the [data-fetching strategy](/docs/basic-features/data-fetching/index.md) you want. We can then determine which authentication providers support this strategy. There are two main patterns:
The first step to identifying which authentication pattern you need is understanding the [data-fetching strategy](/docs/basic-features/data-fetching/overview.md) you want. We can then determine which authentication providers support this strategy. There are two main patterns:

- Use [static generation](/docs/basic-features/pages.md#static-generation-recommended) to server-render a loading state, followed by fetching user data client-side.
- Fetch user data [server-side](/docs/basic-features/pages.md#server-side-rendering) to eliminate a flash of unauthenticated content.
Expand Down Expand Up @@ -156,7 +156,7 @@ For more information on what to do next, we recommend the following sections:
</div>

<div class="card">
<a href="/docs/basic-features/data-fetching/index.md">
<a href="/docs/basic-features/data-fetching/overview.md">
<b>Data Fetching:</b>
<small>Learn more about data fetching in Next.js.</small>
</a>
Expand Down
2 changes: 1 addition & 1 deletion docs/basic-features/data-fetching/get-server-side-props.md
Expand Up @@ -33,7 +33,7 @@ The [`getServerSideProps` API reference](/docs/api-reference/data-fetching/get-s

## When should I use getServerSideProps

You should use `getServerSideProps` only if you need to pre-render a page whose data must be fetched at request time. [Time to First Byte (TTFB)](/learn/seo/web-performance) will be higher than [`getStaticProps`](/docs/basic-features/data-fetching/get-static-props.md) because the server must compute the result on every request, and the result can only be cached by a CDN using `cache-control` headers (which could require extra configuration).
You should use `getServerSideProps` only if you need to pre-render a page whose data must be fetched at request time. [Time to First Byte (TTFB)](https://web.dev/ttfb/) will be higher than [`getStaticProps`](/docs/basic-features/data-fetching/get-static-props.md) because the server must compute the result on every request, and the result can only be cached by a CDN using `cache-control` headers (which could require extra configuration).

If you do not need to pre-render the data, then you should consider fetching data on the [client side](#fetching-data-on-the-client-side).

Expand Down
@@ -1,5 +1,5 @@
---
description: 'Data fetching in Next.js allows you to render your content in different ways, depending on your applications use case. These include pre-rendering with server-side rendering or static-site generation, and incremental static regeneration. Learn how to manage your application data in Next.js.'
description: 'Next.js allows you to fetch data in multiple ways, with pre-rendering, server-side rendering or static-site generation, and incremental static regeneration. Learn how to manage your application data in Next.js.'
---

# Data Fetching Overview
Expand Down
2 changes: 1 addition & 1 deletion docs/basic-features/environment-variables.md
Expand Up @@ -30,7 +30,7 @@ DB_USER=myuser
DB_PASS=mypassword
```

This loads `process.env.DB_HOST`, `process.env.DB_USER`, and `process.env.DB_PASS` into the Node.js environment automatically allowing you to use them in [Next.js data fetching methods](/docs/basic-features/data-fetching/index.md) and [API routes](/docs/api-routes/introduction.md).
This loads `process.env.DB_HOST`, `process.env.DB_USER`, and `process.env.DB_PASS` into the Node.js environment automatically allowing you to use them in [Next.js data fetching methods](/docs/basic-features/data-fetching/overview.md) and [API routes](/docs/api-routes/introduction.md).

For example, using [`getStaticProps`](/docs/basic-features/data-fetching/get-static-props.md):

Expand Down
2 changes: 1 addition & 1 deletion docs/basic-features/pages.md
Expand Up @@ -263,7 +263,7 @@ We've discussed two forms of pre-rendering for Next.js.
We recommend you to read the following sections next:

<div class="card">
<a href="/docs/basic-features/data-fetching/index.md">
<a href="/docs/basic-features/data-fetching/overview.md">
<b>Data Fetching:</b>
<small>Learn more about data fetching in Next.js.</small>
</a>
Expand Down
2 changes: 1 addition & 1 deletion docs/faq.md
Expand Up @@ -39,7 +39,7 @@ description: Get to know more about Next.js with the frequently asked questions.

<details>
<summary>How do I fetch data?</summary>
<p>It's up to you. You can use the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch">fetch API</a> or <a href="https://swr.vercel.app/">SWR</a> inside your React components for remote data fetching; or use our <a href="/docs/basic-features/data-fetching/index.md">data fetching methods</a> for initial data population.</p>
<p>It's up to you. You can use the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch">fetch API</a> or <a href="https://swr.vercel.app/">SWR</a> inside your React components for remote data fetching; or use our <a href="/docs/basic-features/data-fetching/overview.md">data fetching methods</a> for initial data population.</p>
</details>

<details>
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Expand Up @@ -91,7 +91,7 @@ So far, we get:

- Automatic compilation and bundling (with webpack and babel)
- [React Fast Refresh](https://nextjs.org/blog/next-9-4#fast-refresh)
- [Static generation and server-side rendering](/docs/basic-features/data-fetching/index.md) of [`./pages/`](/docs/basic-features/pages.md)
- [Static generation and server-side rendering](/docs/basic-features/data-fetching/overview.md) of [`./pages/`](/docs/basic-features/pages.md)
- [Static file serving](/docs/basic-features/static-file-serving.md). `./public/` is mapped to `/`

In addition, any Next.js application is ready for production from the start, read more in our [Deployment documentation](/docs/deployment.md).
Expand Down
10 changes: 9 additions & 1 deletion docs/manifest.json
Expand Up @@ -18,7 +18,15 @@
"routes": [
{
"title": "Overview",
"path": "/docs/basic-features/data-fetching/index.md"
"path": "/docs/basic-features/data-fetching/index.md",
"redirect": {
"destination": "/docs/basic-features/data-fetching/overview.md",
"permanent": true
}
},
{
"title": "Overview",
"path": "/docs/basic-features/data-fetching/overview.md"
},
{
"title": "getServerSideProps",
Expand Down
2 changes: 1 addition & 1 deletion docs/migrating/from-create-react-app.md
Expand Up @@ -6,7 +6,7 @@ description: Learn how to transition an existing Create React App project to Nex

This guide will help you understand how to transition from an existing non-ejected Create React App project to Next.js. Migrating to Next.js will allow you to:

- Choose which [data fetching](/docs/basic-features/data-fetching/index.md) strategy you want on a per-page basis.
- Choose which [data fetching](/docs/basic-features/data-fetching/overview.md) strategy you want on a per-page basis.
- Use [Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md) to update _existing_ pages by re-rendering them in the background as traffic comes in.
- Use [API Routes](/docs/api-routes/introduction.md).

Expand Down
4 changes: 2 additions & 2 deletions docs/migrating/from-gatsby.md
Expand Up @@ -6,7 +6,7 @@ description: Learn how to transition an existing Gatsby project to Next.js.

This guide will help you understand how to transition from an existing Gatsby project to Next.js. Migrating to Next.js will allow you to:

- Choose which [data fetching](/docs/basic-features/data-fetching/index.md) strategy you want on a per-page basis.
- Choose which [data fetching](/docs/basic-features/data-fetching/overview.md) strategy you want on a per-page basis.
- Use [Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md) to update _existing_ pages by re-rendering them in the background as traffic comes in.
- Use [API Routes](/docs/api-routes/introduction.md).

Expand Down Expand Up @@ -92,7 +92,7 @@ Update any import statements, switch `to` to `href`, and add an `<a>` tag as a c

The largest difference between Gatsby and Next.js is how data fetching is implemented. Gatsby is opinionated with GraphQL being the default strategy for retrieving data across your application. With Next.js, you get to choose which strategy you want (GraphQL is one supported option).

Gatsby uses the `graphql` tag to query data in the pages of your site. This may include local data, remote data, or information about your site configuration. Gatsby only allows the creation of static pages. With Next.js, you can choose on a [per-page basis](/docs/basic-features/pages.md) which [data fetching strategy](/docs/basic-features/data-fetching/index.md) you want. For example, `getServerSideProps` allows you to do server-side rendering. If you wanted to generate a static page, you'd export `getStaticProps` / `getStaticPaths` inside the page, rather than using `pageQuery`. For example:
Gatsby uses the `graphql` tag to query data in the pages of your site. This may include local data, remote data, or information about your site configuration. Gatsby only allows the creation of static pages. With Next.js, you can choose on a [per-page basis](/docs/basic-features/pages.md) which [data fetching strategy](/docs/basic-features/data-fetching/overview.md) you want. For example, `getServerSideProps` allows you to do server-side rendering. If you wanted to generate a static page, you'd export `getStaticProps` / `getStaticPaths` inside the page, rather than using `pageQuery`. For example:

```js
// src/pages/[slug].js
Expand Down
1 change: 0 additions & 1 deletion docs/testing.md
Expand Up @@ -341,7 +341,6 @@ module.exports = {
'/node_modules/',
'^.+\\.module\\.(css|sass|scss)$',
],
testEnvironment: 'jest-environment-jsdom',
}
```

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Expand Up @@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "12.0.9-canary.11"
"version": "12.0.9"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "12.0.9-canary.11",
"version": "12.0.9",
"keywords": [
"react",
"next",
Expand Down

0 comments on commit b950d7e

Please sign in to comment.