diff --git a/docs/02-app/01-building-your-application/07-configuring/15-content-security-policy.mdx b/docs/02-app/01-building-your-application/07-configuring/15-content-security-policy.mdx index 504ee124dbcf9..e332dc2374faa 100644 --- a/docs/02-app/01-building-your-application/07-configuring/15-content-security-policy.mdx +++ b/docs/02-app/01-building-your-application/07-configuring/15-content-security-policy.mdx @@ -209,6 +209,42 @@ export default function Page() { } ``` +## Without Nonces + +For applications that do not require nonces, you can set the CSP header directly in your [`next.config.js`](/docs/app/api-reference/next-config-js) file: + +```js filename="next.config.js" +const cspHeader = ` + default-src 'self'; + script-src 'self' 'unsafe-eval' 'unsafe-inline'; + style-src 'self' 'unsafe-inline'; + img-src 'self' blob: data:; + font-src 'self'; + object-src 'none'; + base-uri 'self'; + form-action 'self'; + frame-ancestors 'none'; + block-all-mixed-content; + upgrade-insecure-requests; +` + +module.exports = { + async headers() { + return [ + { + source: '/(.*)', + headers: [ + { + key: 'Content-Security-Policy', + value: cspHeader.replace(/\n/g, ''), + }, + ], + }, + ] + }, +} +``` + ## Version History We recommend using `v13.4.20+` of Next.js to properly handle and apply nonces. diff --git a/docs/02-app/02-api-reference/04-functions/generate-viewport.mdx b/docs/02-app/02-api-reference/04-functions/generate-viewport.mdx index 93ad5c16e1663..044381e83f178 100644 --- a/docs/02-app/02-api-reference/04-functions/generate-viewport.mdx +++ b/docs/02-app/02-api-reference/04-functions/generate-viewport.mdx @@ -97,7 +97,7 @@ export const viewport = { ``` -### `width`, `initialScale`, and `maximumScale` +### `width`, `initialScale`, `maximumScale` and 'userScalable' > **Good to know**: The `viewport` meta tag is automatically set with the following default values. Usually, manual configuration is unnecessary as the default is sufficient. However, the information is provided for completeness. @@ -106,6 +106,7 @@ export const viewport = { width: 'device-width', initialScale: 1, maximumScale: 1, + userScalable: 1, // Also supported by less commonly used // interactiveWidget: 'resizes-visual', } @@ -114,7 +115,7 @@ export const viewport = { ```html filename=" output" hideLineNumbers ``` diff --git a/docs/02-app/02-api-reference/04-functions/redirect.mdx b/docs/02-app/02-api-reference/04-functions/redirect.mdx index 67cbe3a86ed69..8ba399dfe2b00 100644 --- a/docs/02-app/02-api-reference/04-functions/redirect.mdx +++ b/docs/02-app/02-api-reference/04-functions/redirect.mdx @@ -6,7 +6,7 @@ related: - app/api-reference/functions/permanentRedirect --- -The `redirect` function allows you to redirect the user to another URL. `redirect` can be used in Server Components, Client Components, [Route Handlers](/docs/app/building-your-application/routing/route-handlers), and [Server Actions](/docs/app/building-your-application/data-fetching/server-actions-and-mutations). +The `redirect` function allows you to redirect the user to another URL. `redirect` can be used in Server Components, [Route Handlers](/docs/app/building-your-application/routing/route-handlers), and [Server Actions](/docs/app/building-your-application/data-fetching/server-actions-and-mutations). When used in a [streaming context](/docs/app/building-your-application/routing/loading-ui-and-streaming#what-is-streaming), this will insert a meta tag to emit the redirect on the client side. When used in a server action, it will serve a 303 HTTP redirect response to the caller. Otherwise, it will serve a 307 HTTP redirect response to the caller. @@ -37,6 +37,8 @@ The `type` parameter has no effect when used in Server Components. ## Example +### Server Component + Invoking the `redirect()` function throws a `NEXT_REDIRECT` error and terminates rendering of the route segment in which it was thrown. > **Good to know**: If you need to programmatically redirect the user after a certain event in a Client Component, you can use the [`useRouter`](/docs/app/api-reference/functions/use-router) hook. @@ -62,6 +64,60 @@ export default async function Profile({ params }) { > **Good to know**: `redirect` does not require you to use `return redirect()` as it uses the TypeScript [`never`](https://www.typescriptlang.org/docs/handbook/2/functions.html#never) type. +### Client Component + +`redirect` can be used in a Client Component through a Server Action. If you need to use an event handler to redirect the user, you can use the [`useRouter`](/docs/app/api-reference/functions/use-router) hook. + +```tsx filename="app/client-redirect.tsx" switcher +'use client' + +import { navigate } from './actions' + +export function ClientRedirect() { + return ( +
+ + +
+ ) +} +``` + +```jsx filename="app/client-redirect.jsx" switcher +'use client' + +import { navigate } from './actions' + +export function ClientRedirect() { + return ( +
+ + +
+ ) +} +``` + +```ts filename="app/actions.ts" switcher +'use server' + +import { redirect } from 'next/navigation' + +export async function navigate(data: FormData) { + redirect(`/posts/${data.get('id')}`) +} +``` + +```js filename="app/actions.js" switcher +'use server' + +import { redirect } from 'next/navigation' + +export async function navigate(data) { + redirect(`/posts/${data.get('id')}`) +} +``` + ## FAQ ### Why does `redirect` use 307 and 308? diff --git a/docs/05-community/index.mdx b/docs/05-community/index.mdx index c252cf208e800..3f15f845f218c 100644 --- a/docs/05-community/index.mdx +++ b/docs/05-community/index.mdx @@ -4,7 +4,7 @@ nav_title: Community description: Get involved in the Next.js community. --- -With over 4 million weekly downloads, Next.js has a large and active community of developers across the world. Here's how you can get involved in our community: +With over 5 million weekly downloads, Next.js has a large and active community of developers across the world. Here's how you can get involved in our community: ## Contributing diff --git a/examples/cms-contentful/README.md b/examples/cms-contentful/README.md index 6120452bf9ed9..8fc71d16ea220 100644 --- a/examples/cms-contentful/README.md +++ b/examples/cms-contentful/README.md @@ -73,7 +73,7 @@ This project includes a setup script which you can use to set up the content mod In your Contentful dashboard go to **Settings > General Settings** and copy the **Space ID**. -Next, go to **Settings > API > Content management tokens** and create a new token by clicking **Generate personal token**. This token has the same access rights as the logged in user. **Do not share it publicly**, you will only use it to set up your space and can delete it afterwards. +Next, go to **Settings > CMA tokens** and create a new token by clicking **Create personal access token**. This token has the same access rights as the logged in user. **Do not share it publicly**, you will only use it to set up your space and can delete it afterwards. With the space ID and management access token at hand run the following command: diff --git a/lerna.json b/lerna.json index 38043aeb4cb28..8f30a3ae99681 100644 --- a/lerna.json +++ b/lerna.json @@ -16,5 +16,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "14.0.5-canary.31" + "version": "14.0.5-canary.33" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index 8ef21f6deabd4..7a6fcc9720127 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "14.0.5-canary.31", + "version": "14.0.5-canary.33", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index 712b7e4f82bd0..e499dda82342a 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-next", - "version": "14.0.5-canary.31", + "version": "14.0.5-canary.33", "description": "ESLint configuration used by Next.js.", "main": "index.js", "license": "MIT", @@ -10,7 +10,7 @@ }, "homepage": "https://nextjs.org/docs/app/building-your-application/configuring/eslint#eslint-config", "dependencies": { - "@next/eslint-plugin-next": "14.0.5-canary.31", + "@next/eslint-plugin-next": "14.0.5-canary.33", "@rushstack/eslint-patch": "^1.3.3", "@typescript-eslint/parser": "^5.4.2 || ^6.0.0", "eslint-import-resolver-node": "^0.3.6", diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json index 578769c518d70..7f227cc585773 100644 --- a/packages/eslint-plugin-next/package.json +++ b/packages/eslint-plugin-next/package.json @@ -1,6 +1,6 @@ { "name": "@next/eslint-plugin-next", - "version": "14.0.5-canary.31", + "version": "14.0.5-canary.33", "description": "ESLint plugin for Next.js.", "main": "dist/index.js", "license": "MIT", diff --git a/packages/font/package.json b/packages/font/package.json index 38341eaf62068..a2b8cbc9cfb9c 100644 --- a/packages/font/package.json +++ b/packages/font/package.json @@ -1,6 +1,6 @@ { "name": "@next/font", - "version": "14.0.5-canary.31", + "version": "14.0.5-canary.33", "repository": { "url": "vercel/next.js", "directory": "packages/font" diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index 113942163d528..a4da75acb0443 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "14.0.5-canary.31", + "version": "14.0.5-canary.33", "main": "index.js", "types": "index.d.ts", "license": "MIT", diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index 690b1600fa283..7675147692acd 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "14.0.5-canary.31", + "version": "14.0.5-canary.33", "license": "MIT", "repository": { "type": "git", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index e0f7cad37bb59..0ed325e4ef746 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "14.0.5-canary.31", + "version": "14.0.5-canary.33", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index e87ec20e53c3d..46755f902045e 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "14.0.5-canary.31", + "version": "14.0.5-canary.33", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index 0d54a98265cbb..41f58186f9b70 100644 --- a/packages/next-plugin-storybook/package.json +++ b/packages/next-plugin-storybook/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-storybook", - "version": "14.0.5-canary.31", + "version": "14.0.5-canary.33", "repository": { "url": "vercel/next.js", "directory": "packages/next-plugin-storybook" diff --git a/packages/next-polyfill-module/package.json b/packages/next-polyfill-module/package.json index 0cf2cf6fcb028..b7429e0333845 100644 --- a/packages/next-polyfill-module/package.json +++ b/packages/next-polyfill-module/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-module", - "version": "14.0.5-canary.31", + "version": "14.0.5-canary.33", "description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)", "main": "dist/polyfill-module.js", "license": "MIT", diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index dab2759f8d517..ccac18939d431 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "14.0.5-canary.31", + "version": "14.0.5-canary.33", "description": "A polyfill for non-dead, nomodule browsers.", "main": "dist/polyfill-nomodule.js", "license": "MIT", diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json index 988bd398c865e..96f595a038d6a 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "14.0.5-canary.31", + "version": "14.0.5-canary.33", "private": true, "scripts": { "clean": "node ../../scripts/rm.mjs native", diff --git a/packages/next/package.json b/packages/next/package.json index 2bf1adae096c1..dc2805d172e77 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "14.0.5-canary.31", + "version": "14.0.5-canary.33", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -92,7 +92,7 @@ ] }, "dependencies": { - "@next/env": "14.0.5-canary.31", + "@next/env": "14.0.5-canary.33", "@swc/helpers": "0.5.2", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001406", @@ -147,11 +147,11 @@ "@mswjs/interceptors": "0.23.0", "@napi-rs/cli": "2.16.2", "@napi-rs/triples": "1.1.0", - "@next/polyfill-module": "14.0.5-canary.31", - "@next/polyfill-nomodule": "14.0.5-canary.31", - "@next/react-dev-overlay": "14.0.5-canary.31", - "@next/react-refresh-utils": "14.0.5-canary.31", - "@next/swc": "14.0.5-canary.31", + "@next/polyfill-module": "14.0.5-canary.33", + "@next/polyfill-nomodule": "14.0.5-canary.33", + "@next/react-dev-overlay": "14.0.5-canary.33", + "@next/react-refresh-utils": "14.0.5-canary.33", + "@next/swc": "14.0.5-canary.33", "@opentelemetry/api": "1.6.0", "@playwright/test": "^1.35.1", "@taskr/clear": "1.1.0", diff --git a/packages/react-dev-overlay/package.json b/packages/react-dev-overlay/package.json index 2c7e1c181441b..1c8fe1d63ea99 100644 --- a/packages/react-dev-overlay/package.json +++ b/packages/react-dev-overlay/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-dev-overlay", - "version": "14.0.5-canary.31", + "version": "14.0.5-canary.33", "description": "A development-only overlay for developing React applications.", "repository": { "url": "vercel/next.js", diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index aa6276b8d44e9..b799f8dcb2a5a 100644 --- a/packages/react-refresh-utils/package.json +++ b/packages/react-refresh-utils/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-refresh-utils", - "version": "14.0.5-canary.31", + "version": "14.0.5-canary.33", "description": "An experimental package providing utilities for React Refresh.", "repository": { "url": "vercel/next.js", diff --git a/packages/third-parties/package.json b/packages/third-parties/package.json index 92a37c3635b13..217e7fde980db 100644 --- a/packages/third-parties/package.json +++ b/packages/third-parties/package.json @@ -1,6 +1,6 @@ { "name": "@next/third-parties", - "version": "14.0.5-canary.31", + "version": "14.0.5-canary.33", "repository": { "url": "vercel/next.js", "directory": "packages/third-parties" @@ -26,7 +26,7 @@ "third-party-capital": "1.0.20" }, "devDependencies": { - "next": "14.0.5-canary.31", + "next": "14.0.5-canary.33", "outdent": "0.8.0", "prettier": "2.5.1" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3511dc2a3b6bc..95456e4e7c7cd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -741,7 +741,7 @@ importers: packages/eslint-config-next: dependencies: '@next/eslint-plugin-next': - specifier: 14.0.5-canary.31 + specifier: 14.0.5-canary.33 version: link:../eslint-plugin-next '@rushstack/eslint-patch': specifier: ^1.3.3 @@ -806,7 +806,7 @@ importers: packages/next: dependencies: '@next/env': - specifier: 14.0.5-canary.31 + specifier: 14.0.5-canary.33 version: link:../next-env '@swc/helpers': specifier: 0.5.2 @@ -933,19 +933,19 @@ importers: specifier: 1.1.0 version: 1.1.0 '@next/polyfill-module': - specifier: 14.0.5-canary.31 + specifier: 14.0.5-canary.33 version: link:../next-polyfill-module '@next/polyfill-nomodule': - specifier: 14.0.5-canary.31 + specifier: 14.0.5-canary.33 version: link:../next-polyfill-nomodule '@next/react-dev-overlay': - specifier: 14.0.5-canary.31 + specifier: 14.0.5-canary.33 version: link:../react-dev-overlay '@next/react-refresh-utils': - specifier: 14.0.5-canary.31 + specifier: 14.0.5-canary.33 version: link:../react-refresh-utils '@next/swc': - specifier: 14.0.5-canary.31 + specifier: 14.0.5-canary.33 version: link:../next-swc '@opentelemetry/api': specifier: 1.6.0 @@ -1599,7 +1599,7 @@ importers: version: 1.0.20 devDependencies: next: - specifier: 14.0.5-canary.31 + specifier: 14.0.5-canary.33 version: link:../next outdent: specifier: 0.8.0