useLoadScript
The useLoadScript
hook loads an external script tag on the client-side.
Example code
Anchor link to section titled "Example code"
The useLoadScript
hook takes the following arguments:
Parameter | Required | Description |
---|---|---|
url |
Yes | The URL string for the external script. |
options |
No | An object that gets passed to the underlying <script> tag. Currently only supports `{module?: true, in?: 'body' |
Return value
Anchor link to section titled "Return value"The useLoadScript
hook returns the following values that allow you to understand the state of the external script you are loading:
Value | Description |
---|---|
loading |
The script is still loading. For example, the script tag can be on the page but the resource might not be fully loaded yet while in this state. |
done |
The script is fully loaded and ready to use. |
error |
There was an error loading the script. |