Skip to content
Discussion options

You must be logged in to vote

For CSP compliance, styled-components supports passing a nonce via StyleSheetManager:

<StyleSheetManager nonce={yourNonceValue}>
  <App />
</StyleSheetManager>

This adds the nonce attribute to all injected <style> tags, allowing them to pass CSP style-src checks without unsafe-inline.

The upcoming release also includes changes to RSC style injection (plain inline <style> tags for server components). If you are using RSC, the nonce handling in that path may be relevant to your setup.

You can test the prerelease:

npm install styled-components@test

Staged release PR: #5687

Replies: 4 comments 6 replies

Comment options

You must be logged in to vote
5 replies
@IliaTheKeeper
Comment options

@ghost
Comment options

@IliaTheKeeper
Comment options

@apw-globotron
Comment options

@ghost
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@marco-origam
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by quantizor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
7 participants