Skip to content

docs: add CSP nonce documentation#996

Open
quantizor wants to merge 1 commit intomainfrom
docs/csp-nonce-support
Open

docs: add CSP nonce documentation#996
quantizor wants to merge 1 commit intomainfrom
docs/csp-nonce-support

Conversation

@quantizor
Copy link
Copy Markdown
Contributor

Summary

Add comprehensive CSP nonce documentation covering all supported frameworks.

Changes

Security page — new "Content Security Policy" section with all nonce configuration methods:

  • StyleSheetManager nonce prop (recommended)
  • ServerStyleSheet constructor option
  • <meta property="csp-nonce"> auto-detection (Vite)
  • <meta name="sc-nonce"> auto-detection
  • __webpack_nonce__ legacy fallback

SSR page — framework-specific CSP guides:

  • Next.js App Router: middleware nonce generation → StyledComponentsRegistry with nonce prop → layout.tsx
  • Remix / React Router v7: entry.server.tsx nonce flow with security note about keeping nonce server-only

Vite tooling page — CSP nonce section with html.cspNonce config and Express middleware example

API referencenonce prop added to StyleSheetManager table

Companion to styled-components/styled-components#5693

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
styled-components Ready Ready Preview, Comment Mar 19, 2026 7:08pm

Request Review

- Add Content Security Policy section to security page with all nonce
  configuration methods (StyleSheetManager prop, ServerStyleSheet option,
  meta tag auto-detection, __webpack_nonce__)
- Add Next.js App Router CSP nonce guide with middleware + registry example
- Add Remix/React Router v7 CSP nonce guide with entry.server.tsx example
- Add Vite CSP nonce guide using html.cspNonce auto-detection
- Add nonce prop to StyleSheetManager API reference

Companion to styled-components/styled-components#5693
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant