Skip to content

fix: add suppressHydrationWarning when using nonce and disableNextScript #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

jonathanturcotte
Copy link

The problem

When using disableNextScript and a nonce at the same time, React complains about a hydration mismatch between a nonce parameter with some value on the server, and a nonce value of "" in the client.

The cause

Nonces are removed by the browser from DOM elements to prevent them from being exposed to client side code. This happens before React hydrates the page, so it causes a mismatch.

The fix

Set suppressHydrationWarning on the vanilla script tag if nonce is being used.

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