From c3b0757a24919e990ad1b8ba6eabade875c0ceb0 Mon Sep 17 00:00:00 2001 From: Lee Robinson Date: Tue, 15 Feb 2022 19:43:13 -0600 Subject: [PATCH 1/8] Add documentation for on-demand revaliation. --- .../data-fetching/get-static-paths.md | 8 +- docs/api-routes/response-helpers.md | 1 + .../data-fetching/client-side.md | 11 +++ .../data-fetching/get-server-side-props.md | 4 + .../data-fetching/get-static-paths.md | 12 ++- .../data-fetching/get-static-props.md | 15 +++- .../incremental-static-regeneration.md | 73 ++++++++++++++++++- 7 files changed, 112 insertions(+), 12 deletions(-) diff --git a/docs/api-reference/data-fetching/get-static-paths.md b/docs/api-reference/data-fetching/get-static-paths.md index 9175bed28a72..42204ee559c0 100644 --- a/docs/api-reference/data-fetching/get-static-paths.md +++ b/docs/api-reference/data-fetching/get-static-paths.md @@ -7,10 +7,12 @@ description: API reference for `getStaticPaths`. Learn how to fetch data and gen
Version History -| Version | Changes | -| -------- | --------------------------------------------------------------------------------------------------------------- | +| Version | Changes | +| ------- | ------- | + +| `v12.1.0` | [On-demand Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md#testing-on-demand-isr-during-development) added (beta). | | `v9.5.0` | Stable [Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md) | -| `v9.3.0` | `getStaticPaths` introduced. | +| `v9.3.0` | `getStaticPaths` introduced. |
diff --git a/docs/api-routes/response-helpers.md b/docs/api-routes/response-helpers.md index 41673745b259..e04810933919 100644 --- a/docs/api-routes/response-helpers.md +++ b/docs/api-routes/response-helpers.md @@ -12,6 +12,7 @@ The included helpers are: - `res.json(body)` - Sends a JSON response. `body` must be a [serializable object](https://developer.mozilla.org/en-US/docs/Glossary/Serialization) - `res.send(body)` - Sends the HTTP response. `body` can be a `string`, an `object` or a `Buffer` - `res.redirect([status,] path)` - Redirects to a specified path or URL. `status` must be a valid [HTTP status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes). If not specified, `status` defaults to "307" "Temporary redirect". +- `res.unstable_revalidate(urlPath)` - [Revalidate a page on demand](/docs/basic-features/data-fetching/incremental-static-regeneration.md#testing-on-demand-isr-during-development) using `getStaticProps`. `urlPath` must be a `string`. ## Setting the status code of a response diff --git a/docs/basic-features/data-fetching/client-side.md b/docs/basic-features/data-fetching/client-side.md index 97cad41a1a8a..6b1768a6e901 100644 --- a/docs/basic-features/data-fetching/client-side.md +++ b/docs/basic-features/data-fetching/client-side.md @@ -68,3 +68,14 @@ function Profile() { ) } ``` + +## Related + +For more information on what to do next, we recommend the following sections: + +
+ + Routing: + Learn more about routing in Next.js. + +
diff --git a/docs/basic-features/data-fetching/get-server-side-props.md b/docs/basic-features/data-fetching/get-server-side-props.md index 53952a44942e..377a775aa5a2 100644 --- a/docs/basic-features/data-fetching/get-server-side-props.md +++ b/docs/basic-features/data-fetching/get-server-side-props.md @@ -74,6 +74,10 @@ export async function getServerSideProps() { export default Page ``` +## Related + +For more information on what to do next, we recommend the following sections: +
getServerSideProps API Reference diff --git a/docs/basic-features/data-fetching/get-static-paths.md b/docs/basic-features/data-fetching/get-static-paths.md index cb9b5b68b438..ecb2e7f57c8c 100644 --- a/docs/basic-features/data-fetching/get-static-paths.md +++ b/docs/basic-features/data-fetching/get-static-paths.md @@ -19,7 +19,7 @@ export async function getStaticPaths() { } ``` -Note that`getStaticProps` **must** be used with `getStaticPaths`, and that you **cannot** use it with [`getServerSideProps`](/docs/basic-features/data-fetching/get-server-side-props.md). +`getStaticPaths` **must** be used with `getStaticProps`. You **cannot** use it with [`getServerSideProps`](/docs/basic-features/data-fetching/get-server-side-props.md). The [`getStaticPaths` API reference](/docs/api-reference/data-fetching/get-static-paths.md) covers all parameters and props that can be used with `getStaticPaths`. @@ -35,7 +35,11 @@ You should use `getStaticPaths` if you’re statically pre-rendering pages that ## When does getStaticPaths run -`getStaticPaths` only runs at build time on server-side. If you're using [Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md), `getStaticPaths` can also be run on-demand _in the background_, but still only on the server-side. +`getStaticPaths` always runs on the server and never on the client. You can validate code written inside `getStaticPaths` is removed from the client-side bundle [with this tool](https://next-code-elimination.vercel.app/). + +- `getStaticPaths` runs during `next build` for Pages included in `paths` +- `getStaticPaths` runs on-demand in the background when using `fallback: true` +- `getStaticPaths` runs on-demand blocking rendering when using `fallback: blocking` ## Where can I use getStaticPaths @@ -47,6 +51,10 @@ Note that you must use export `getStaticPaths` as a standalone function — it w In development (`next dev`), `getStaticPaths` will be called on every request. +## Related + +For more information on what to do next, we recommend the following sections: +
getStaticPaths API Reference diff --git a/docs/basic-features/data-fetching/get-static-props.md b/docs/basic-features/data-fetching/get-static-props.md index 0b483f5a6b99..1cb2e1bc059d 100644 --- a/docs/basic-features/data-fetching/get-static-props.md +++ b/docs/basic-features/data-fetching/get-static-props.md @@ -23,9 +23,16 @@ You should use `getStaticProps` if: - The data can be publicly cached (not user-specific) - The page must be pre-rendered (for SEO) and be very fast — `getStaticProps` generates `HTML` and `JSON` files, both of which can be cached by a CDN for performance +## When does getStaticProps run + +`getStaticProps` always runs on the server and never on the client. You can validate code written inside `getStaticProps` is removed from the client-side bundle [with this tool](https://next-code-elimination.vercel.app/). + +- `getStaticProps` always runs during `next build` +- `getStaticProps` runs on-demand in the background when using `revalidate` + When combined with [Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md), `getStaticProps` will run in the background while the stale page is being revalidated, and the fresh page served to the browser. -Because `getStaticProps` runs at build time, it does **not** have access to the incoming request (such as query parameters or `HTTP` headers) as it generates static `HTML`. If you need access to the request for your page, consider using [Middleware](/docs/middleware.md) in addition to `getStaticProps`. +`getStaticProps` does not have access to the incoming request (such as query parameters or `HTTP` headers) as it generates static `HTML`. If you need access to the request for your page, consider using [Middleware](/docs/middleware.md) in addition to `getStaticProps`. ## Using getStaticProps to fetch data from a CMS @@ -128,9 +135,11 @@ In development (`next dev`), `getStaticProps` will be called on every request. ## Preview Mode -In some cases, you might want to temporarily bypass Static Generation and render the page at **request time** instead of build time. For example, you might be using a headless CMS and want to preview drafts before they're published. +You can temporarily bypass static generation and render the page at **request time** instead of build time using [**Preview Mode**](/docs/advanced-features/preview-mode.md). For example, you might be using a headless CMS and want to preview drafts before they're published. + +## Related -This use case is supported in Next.js by the [**Preview Mode**](/docs/advanced-features/preview-mode.md) feature. +For more information on what to do next, we recommend the following sections:
diff --git a/docs/basic-features/data-fetching/incremental-static-regeneration.md b/docs/basic-features/data-fetching/incremental-static-regeneration.md index abe7f13c8154..ff942815e473 100644 --- a/docs/basic-features/data-fetching/incremental-static-regeneration.md +++ b/docs/basic-features/data-fetching/incremental-static-regeneration.md @@ -16,9 +16,11 @@ description: 'Learn how to create or update static pages at runtime with Increme
Version History -| Version | Changes | -| -------- | ---------------- | -| `v9.5.0` | Base Path added. | +| Version | Changes | +| --------- | --------------------------------------------------------------------------------------- | +| `v12.1.0` | On-demand ISR added (beta). | +| `v12.0.0` | [Bot-aware ISR fallback](https://nextjs.org/blog/next-12#bot-aware-isr-fallback) added. | +| `v9.5.0` | Base Path added. |
@@ -85,7 +87,59 @@ When a request is made to a page that was pre-rendered at build time, it will in When a request is made to a path that hasn’t been generated, Next.js will server-render the page on the first request. Future requests will serve the static file from the cache. ISR on Vercel [persists the cache globally and handles rollbacks](https://vercel.com/docs/concepts/next.js/incremental-static-regeneration). -## Error Handling and Revalidation +## On-demand revalidation (beta) + +If you set a `revalidate` time of `60`, all visitors will see the same generated version of your site for one minute. The only way to invalidate the cache is from someone visiting that page after the minute has passed. + +Starting with `v12.1.0`, Next.js supports on-demand Incremental Static Regeneration to manually purge the Next.js cache for a specific page. This makes it easier to update your site when: + +- Content from your headless CMS is created or updated +- Ecommerce metadata changes (price, description, category, reviews, etc.) + +First, create a secret token only known by your Next.js app. This secret will be used to prevent unauthorized access to the revalidation API Route. You can access the route (either manually or with a webhook) with the following URL structure: + +```bash +https:///api/revalidate?secret= +``` + +Next, add the secret as an [Environment Variable](/docs/basic-features/environment-variables.md) to your application. Finally, create the revalidation API Route: + +```jsx +// pages/api/revalidate.js + +export default async function handler(req, res) { + // Check for secret to confirm this is a valid request + if (req.query.secret !== process.env.MY_SECRET_TOKEN) { + return res.status(401).json({ message: 'Invalid token' }) + } + + try { + await res.unstable_revalidate('/path-to-revalidate') + return res.json({ revalidated: true }) + } catch (err) { + // If there was an error, Next.js will continue + // to show the last successfully generated page + return res.status(500).send('Error revalidating') + } +} +``` + +Inside `getStaticProps`, you do not need to specific `revalidate` to use on-demand revalidation. If `revalidate` is omitted, Next.js will use the default value of `false` (no revalidation) and only ever revalidate the page on-demand when `unstable_revalidate()` is used. + +[View our demo](https://on-demand-isr.vercel.app) to see on-demand revalidation in action and provide feedback. + +### Testing on-demand ISR during development + +When running locally with `next dev`, `getStaticProps` is invoked on every request. To verify your on-demand ISR configuration is correct, you will need to create a [production build](/docs/api-reference/cli.md#build) and start the [production server](/docs/api-reference/cli.md#production): + +```bash +$ next build +$ next start +``` + +Then, you are able to validate static pages are successfully revalidated. + +## Error handling and revalidation If there is an error inside `getStaticProps` when handling background regeneration, or you manually throw an error, the last successfully generated page will continue to show. On the next subsequent request, Next.js will retry calling `getStaticProps`. @@ -114,3 +168,14 @@ export async function getStaticProps() { } } ``` + +## Related + +For more information on what to do next, we recommend the following sections: + +
From 7292ac2037a5e4d9e938e0c3abc7e89f3e6e7ddd Mon Sep 17 00:00:00 2001 From: Lee Robinson Date: Tue, 15 Feb 2022 20:57:43 -0600 Subject: [PATCH 2/8] Fix typos --- .../data-fetching/incremental-static-regeneration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/basic-features/data-fetching/incremental-static-regeneration.md b/docs/basic-features/data-fetching/incremental-static-regeneration.md index ff942815e473..7caaf4a696a1 100644 --- a/docs/basic-features/data-fetching/incremental-static-regeneration.md +++ b/docs/basic-features/data-fetching/incremental-static-regeneration.md @@ -124,7 +124,7 @@ export default async function handler(req, res) { } ``` -Inside `getStaticProps`, you do not need to specific `revalidate` to use on-demand revalidation. If `revalidate` is omitted, Next.js will use the default value of `false` (no revalidation) and only ever revalidate the page on-demand when `unstable_revalidate()` is used. +Inside `getStaticProps`, you do not need to specify `revalidate` to use on-demand revalidation. If `revalidate` is omitted, Next.js will use the default value of `false` (no revalidation) and only revalidate the page on-demand when `unstable_revalidate()` is called. [View our demo](https://on-demand-isr.vercel.app) to see on-demand revalidation in action and provide feedback. From eb5d37f1c7069ffa9ef6c880fe15824a580c4f2a Mon Sep 17 00:00:00 2001 From: Lee Robinson Date: Thu, 17 Feb 2022 08:06:32 -0600 Subject: [PATCH 3/8] Fix URLs --- docs/api-reference/data-fetching/get-static-paths.md | 2 +- docs/api-routes/response-helpers.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api-reference/data-fetching/get-static-paths.md b/docs/api-reference/data-fetching/get-static-paths.md index 42204ee559c0..f78e56122ad4 100644 --- a/docs/api-reference/data-fetching/get-static-paths.md +++ b/docs/api-reference/data-fetching/get-static-paths.md @@ -10,7 +10,7 @@ description: API reference for `getStaticPaths`. Learn how to fetch data and gen | Version | Changes | | ------- | ------- | -| `v12.1.0` | [On-demand Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md#testing-on-demand-isr-during-development) added (beta). | +| `v12.1.0` | [On-demand Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md#on-demand-revalidation-beta) added (beta). | | `v9.5.0` | Stable [Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md) | | `v9.3.0` | `getStaticPaths` introduced. | diff --git a/docs/api-routes/response-helpers.md b/docs/api-routes/response-helpers.md index e04810933919..0e3af609fbc6 100644 --- a/docs/api-routes/response-helpers.md +++ b/docs/api-routes/response-helpers.md @@ -12,7 +12,7 @@ The included helpers are: - `res.json(body)` - Sends a JSON response. `body` must be a [serializable object](https://developer.mozilla.org/en-US/docs/Glossary/Serialization) - `res.send(body)` - Sends the HTTP response. `body` can be a `string`, an `object` or a `Buffer` - `res.redirect([status,] path)` - Redirects to a specified path or URL. `status` must be a valid [HTTP status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes). If not specified, `status` defaults to "307" "Temporary redirect". -- `res.unstable_revalidate(urlPath)` - [Revalidate a page on demand](/docs/basic-features/data-fetching/incremental-static-regeneration.md#testing-on-demand-isr-during-development) using `getStaticProps`. `urlPath` must be a `string`. +- `res.unstable_revalidate(urlPath)` - [Revalidate a page on demand](/docs/basic-features/data-fetching/incremental-static-regeneration.md#on-demand-revalidation-beta) using `getStaticProps`. `urlPath` must be a `string`. ## Setting the status code of a response From fd5c7738cad466d31b22d4e6276357ad01bd9046 Mon Sep 17 00:00:00 2001 From: Lee Robinson Date: Thu, 17 Feb 2022 08:19:24 -0600 Subject: [PATCH 4/8] Fix --- .../data-fetching/incremental-static-regeneration.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/basic-features/data-fetching/incremental-static-regeneration.md b/docs/basic-features/data-fetching/incremental-static-regeneration.md index 7caaf4a696a1..5c9e8a474991 100644 --- a/docs/basic-features/data-fetching/incremental-static-regeneration.md +++ b/docs/basic-features/data-fetching/incremental-static-regeneration.md @@ -18,7 +18,7 @@ description: 'Learn how to create or update static pages at runtime with Increme | Version | Changes | | --------- | --------------------------------------------------------------------------------------- | -| `v12.1.0` | On-demand ISR added (beta). | +| `v12.1.0` | On-demand ISR added (Beta). | | `v12.0.0` | [Bot-aware ISR fallback](https://nextjs.org/blog/next-12#bot-aware-isr-fallback) added. | | `v9.5.0` | Base Path added. | @@ -87,7 +87,7 @@ When a request is made to a page that was pre-rendered at build time, it will in When a request is made to a path that hasn’t been generated, Next.js will server-render the page on the first request. Future requests will serve the static file from the cache. ISR on Vercel [persists the cache globally and handles rollbacks](https://vercel.com/docs/concepts/next.js/incremental-static-regeneration). -## On-demand revalidation (beta) +## On-demand Revalidation (Beta) If you set a `revalidate` time of `60`, all visitors will see the same generated version of your site for one minute. The only way to invalidate the cache is from someone visiting that page after the minute has passed. @@ -96,6 +96,10 @@ Starting with `v12.1.0`, Next.js supports on-demand Incremental Static Regenerat - Content from your headless CMS is created or updated - Ecommerce metadata changes (price, description, category, reviews, etc.) +Inside `getStaticProps`, you do not need to specify `revalidate` to use on-demand revalidation. If `revalidate` is omitted, Next.js will use the default value of `false` (no revalidation) and only revalidate the page on-demand when `unstable_revalidate` is called. + +### Usage + First, create a secret token only known by your Next.js app. This secret will be used to prevent unauthorized access to the revalidation API Route. You can access the route (either manually or with a webhook) with the following URL structure: ```bash @@ -124,8 +128,6 @@ export default async function handler(req, res) { } ``` -Inside `getStaticProps`, you do not need to specify `revalidate` to use on-demand revalidation. If `revalidate` is omitted, Next.js will use the default value of `false` (no revalidation) and only revalidate the page on-demand when `unstable_revalidate()` is called. - [View our demo](https://on-demand-isr.vercel.app) to see on-demand revalidation in action and provide feedback. ### Testing on-demand ISR during development From b00cc38983c27f240ed9bbb2902ab02ad2330354 Mon Sep 17 00:00:00 2001 From: Lee Robinson Date: Thu, 17 Feb 2022 08:44:14 -0600 Subject: [PATCH 5/8] Consistent capitalization --- docs/api-reference/data-fetching/get-static-paths.md | 2 +- docs/middleware.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api-reference/data-fetching/get-static-paths.md b/docs/api-reference/data-fetching/get-static-paths.md index f78e56122ad4..5b86474d8890 100644 --- a/docs/api-reference/data-fetching/get-static-paths.md +++ b/docs/api-reference/data-fetching/get-static-paths.md @@ -10,7 +10,7 @@ description: API reference for `getStaticPaths`. Learn how to fetch data and gen | Version | Changes | | ------- | ------- | -| `v12.1.0` | [On-demand Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md#on-demand-revalidation-beta) added (beta). | +| `v12.1.0` | [On-demand Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md#on-demand-revalidation-beta) added (Beta). | | `v9.5.0` | Stable [Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md) | | `v9.3.0` | `getStaticPaths` introduced. | diff --git a/docs/middleware.md b/docs/middleware.md index c56eb4df4298..d204f99a6c4d 100644 --- a/docs/middleware.md +++ b/docs/middleware.md @@ -10,7 +10,7 @@ description: Learn how to use Middleware in Next.js to run code before a request | Version | Changes | | --------- | ------------------------------------------------------------------------------------------ | | `v12.0.9` | Enforce absolute URLs in Edge Runtime ([PR](https://github.com/vercel/next.js/pull/33410)) | -| `v12.0.0` | Middleware (beta) added. | +| `v12.0.0` | Middleware (Beta) added. | From 8807ce54e5b5c35e235b95ff8f608405b19cc322 Mon Sep 17 00:00:00 2001 From: Lee Robinson Date: Thu, 17 Feb 2022 08:47:54 -0600 Subject: [PATCH 6/8] Fix version history --- .../data-fetching/get-static-props.md | 14 ++++++++------ .../data-fetching/get-static-props.md | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/api-reference/data-fetching/get-static-props.md b/docs/api-reference/data-fetching/get-static-props.md index 7e04d1d9252e..c5f34276ffa8 100644 --- a/docs/api-reference/data-fetching/get-static-props.md +++ b/docs/api-reference/data-fetching/get-static-props.md @@ -7,12 +7,14 @@ description: API reference for `getStaticProps`. Learn how to use `getStaticProp
Version History -| Version | Changes | -| --------- | ----------------------------------------------------------------------------------------------------------------- | -| `v10.0.0` | `locale`, `locales`, `defaultLocale`, and `notFound` options added. | -| `v9.5.0` | Stable [Incremental Static Regeneration](https://nextjs.org/blog/next-9-5#stable-incremental-static-regeneration) | -| `v9.3.0` | `getStaticProps` introduced. | -| `v10.0.0` | `fallback: 'blocking'` return option added. | +| Version | Changes | +| ------- | ------- | + +| `v12.1.0` | [On-demand Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md#on-demand-revalidation-beta) added (Beta). | +| `v10.0.0` | `locale`, `locales`, `defaultLocale`, and `notFound` options added. | +| `v10.0.0` | `fallback: 'blocking'` return option added. | +| `v9.5.0` | Stable [Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md) | +| `v9.3.0` | `getStaticProps` introduced. |
diff --git a/docs/basic-features/data-fetching/get-static-props.md b/docs/basic-features/data-fetching/get-static-props.md index 1cb2e1bc059d..dae38ab51431 100644 --- a/docs/basic-features/data-fetching/get-static-props.md +++ b/docs/basic-features/data-fetching/get-static-props.md @@ -28,7 +28,8 @@ You should use `getStaticProps` if: `getStaticProps` always runs on the server and never on the client. You can validate code written inside `getStaticProps` is removed from the client-side bundle [with this tool](https://next-code-elimination.vercel.app/). - `getStaticProps` always runs during `next build` -- `getStaticProps` runs on-demand in the background when using `revalidate` +- `getStaticProps` runs in the background when using `revalidate` +- `getStaticProps` runs on-demand in the background when using [`unstable_revalidate`](/docs/basic-features/data-fetching/incremental-static-regeneration.md#on-demand-revalidation-beta) When combined with [Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md), `getStaticProps` will run in the background while the stale page is being revalidated, and the fresh page served to the browser. From 4e72c7a83385a468e324d4c250ffd345651e4de7 Mon Sep 17 00:00:00 2001 From: Lee Robinson Date: Thu, 17 Feb 2022 07:48:54 -0700 Subject: [PATCH 7/8] Update docs/basic-features/data-fetching/get-static-props.md Co-authored-by: Steven --- docs/basic-features/data-fetching/get-static-props.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/basic-features/data-fetching/get-static-props.md b/docs/basic-features/data-fetching/get-static-props.md index dae38ab51431..a5a5190fda97 100644 --- a/docs/basic-features/data-fetching/get-static-props.md +++ b/docs/basic-features/data-fetching/get-static-props.md @@ -33,7 +33,7 @@ You should use `getStaticProps` if: When combined with [Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md), `getStaticProps` will run in the background while the stale page is being revalidated, and the fresh page served to the browser. -`getStaticProps` does not have access to the incoming request (such as query parameters or `HTTP` headers) as it generates static `HTML`. If you need access to the request for your page, consider using [Middleware](/docs/middleware.md) in addition to `getStaticProps`. +`getStaticProps` does not have access to the incoming request (such as query parameters or HTTP headers) as it generates static HTML. If you need access to the request for your page, consider using [Middleware](/docs/middleware.md) in addition to `getStaticProps`. ## Using getStaticProps to fetch data from a CMS From 76e21b1ae219d12240c0e365ff5df05b4f21857f Mon Sep 17 00:00:00 2001 From: Lee Robinson Date: Thu, 17 Feb 2022 08:01:24 -0700 Subject: [PATCH 8/8] Update docs/basic-features/data-fetching/incremental-static-regeneration.md Co-authored-by: Steven --- .../data-fetching/incremental-static-regeneration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/basic-features/data-fetching/incremental-static-regeneration.md b/docs/basic-features/data-fetching/incremental-static-regeneration.md index 5c9e8a474991..fa0a1b350e8d 100644 --- a/docs/basic-features/data-fetching/incremental-static-regeneration.md +++ b/docs/basic-features/data-fetching/incremental-static-regeneration.md @@ -98,7 +98,7 @@ Starting with `v12.1.0`, Next.js supports on-demand Incremental Static Regenerat Inside `getStaticProps`, you do not need to specify `revalidate` to use on-demand revalidation. If `revalidate` is omitted, Next.js will use the default value of `false` (no revalidation) and only revalidate the page on-demand when `unstable_revalidate` is called. -### Usage +### Using On-Demand Revalidation First, create a secret token only known by your Next.js app. This secret will be used to prevent unauthorized access to the revalidation API Route. You can access the route (either manually or with a webhook) with the following URL structure: