React (CRA/Vite, CSR)

Load the script in index.html (public) and call initWidget in a client-side effect:

<!-- public/index.html -->
<script
  async
  src="<https://glyph-core.s3.us-east-1.amazonaws.com/test/Glyph-unified-bundle.js>"
></script>
// App.tsx
import { useEffect } from "react";

export default function App() {
  useEffect(() => {
    let mounted = true;

    (async () => {
      if (!mounted) return;

      await window.Glyph?.initWidget({
        theme: {
          primaryColor: "#007bff",
          placement: "bottom-right",
          theme: "light",
        },
        supportedChains: ["base"],
      });
    })();

    return () => {
      mounted = false;
      // Optional cleanup:
      window.Glyph?.destroyReactIframe?.();
    };
  }, []);

  return <div>My App</div>;
}

Last updated