--- description: How to set a Content Security Policy in Next.js with nonces, what it costs in rendering, and how to report violations to Report URI. --- # Next.js Next.js has the most complete CSP story of any framework here, and also the most honest one: it documents not just how to add a nonce, but what adopting one costs you. That trade-off is the thing to understand before you start. ## What Next.js gives you - Nonce generation in the proxy layer (`proxy.ts`, previously middleware), set on both the `Content-Security-Policy` header and a custom `x-nonce` header. - Automatic nonce application during server-side rendering. Next.js parses the CSP header, extracts the `'nonce-{value}'` pattern, and attaches it to framework scripts, page bundles, its own inline styles and scripts, and any `