Skip to content

feature: Add integrity & crossOrigin options to useScript#717

Open
DanielBoa wants to merge 3 commits intojuliencrn:masterfrom
DanielBoa:add-integrity-option-to-use-script
Open

feature: Add integrity & crossOrigin options to useScript#717
DanielBoa wants to merge 3 commits intojuliencrn:masterfrom
DanielBoa:add-integrity-option-to-use-script

Conversation

@DanielBoa
Copy link

@DanielBoa DanielBoa commented Mar 10, 2026

What

Add new options to allow the integrity of a script loaded via useScript to be validated using Subresource Integrity (SRI).

Two new properties:

  • integrity - allows a sha to be set for the external resource (further reading)
  • crossOrigin - allows the setting of the crossorigin attribute, if omitted and integrity is set this is automatically set to anonymous (further reading)

Why

I encountered this hook and wanted to use it but had the lack of this feature prevented me from doing so in the context.

Demo

https://codesandbox.io/p/sandbox/rdnw2y

Misc

  • I changed the src of each test case as the tests were colliding. This is because the useScript hook has a module scoped cache keyed by src
  • Linting passed, but I had to manually install eslint-plugin-import to get the linting to work at all, I've avoided including that as I wasn't sure why this was the case. Also the linter seemed to flag several issues in other hooks which I ignored

@changeset-bot
Copy link

changeset-bot bot commented Mar 10, 2026

⚠️ No Changeset found

Latest commit: 8192265

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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