The no-restricted-globals rule prevents usage of browser globals that are not available in the sandboxed web worker environment.
Rule details
This rule blocks usage of the following globals:
importScripts(): a worker function that doesn’t work in the UI extensions environment.
addEventListener() / removeEventListener(): global event listeners don’t work for DOM events.
location: not available in workers.
history: not available in workers.
navigator: WorkerNavigator in workers, missing most browser Navigator APIs.
Instead of the above browser globals, use the following UI extension alternatives:
Examples
importScripts()
Instead of using importScripts():
Use ES modules:
Event listeners
Instead of using global event listeners:
Use React component event props:
location and history
Instead of accessing location or history:
Use context for location information:
Use actions and <Link> for navigation:
navigator
In the sandboxed web worker, navigator is WorkerNavigator, not the full browser Navigator. Properties like navigator.language return worker-context values instead of the HubSpot user’s locale, and most other Navigator properties (clipboard, geolocation, mediaDevices, etc.) are missing entirely.
Instead of accessing navigator:
Use context for locale information:
Local variables
Local variables with these names are allowed:
Last modified on May 4, 2026