There are 2 common approaches to adding JavaScript to a page.
React elements (preferred) — You can use React components as custom elements using Remount.
Onmount behaviors — For sites that don't use React, you can use Onmount to attach behaviors to DOM elements.