## Hash-based CSP with Subresource Integrity (Experimental)
## Subresource Integrity (Experimental)
As an alternative to nonces, Next.js offers experimental support for hash-based CSP using Subresource Integrity (SRI). This approach allows you to maintain static generation while still having a strict CSP.
As an alternative to nonces, Next.js offers experimental support for hash-based CSP using Subresource Integrity (SRI). This approach allows you to maintain static generation while still having a strict CSP.
> **Warning**: This feature is experimental and only available with webpack bundler in App Router applications.
> **Good to know**: This feature is experimental and only available with webpack bundler in App Router applications.
### How SRI works
### How SRI works
Instead of using nonces, SRI generates cryptographic hashes of your JavaScript and CSS files at build time. These hashes are then used in your CSP policy to allow specific scripts and styles.
Instead of using nonces, SRI generates cryptographic hashes of your JavaScript files at build time. These hashes are added as `integrity` attributes to script tags, allowing browsers to verify that files haven'tbeenmodifiedduringtransit.
### Enabling SRI
### Enabling SRI
...
@@ -474,15 +474,17 @@ const nextConfig = {
...
@@ -474,15 +474,17 @@ const nextConfig = {
module.exports = nextConfig
module.exports = nextConfig
```
```
### Using SRI with CSP
### CSP configuration with SRI
When SRI is enabled, you can use hash-based CSP policies: