<WormkeyOverlay /> component is a React component designed for Next.js and React applications. It automatically loads the Wormkey overlay script, which displays an owner control bar when your app is viewed through a wormhole URL.
Installation
Usage
Add the component to your root layout (e.g., Next.jsapp/layout.tsx):
Props
Full overlay script URL. If provided, this takes precedence over
gatewayUrl and slug.Example: https://wormkey.run/.wormkey/overlay.js?slug=pale-snow-91Gateway base URL used with
slug to construct the script URL.Default: Falls back to process.env.NEXT_PUBLIC_WORMKEY_GATEWAY_URLExample: https://wormkey.runThe wormhole slug identifier. If omitted, the component automatically derives it from the URL path when viewing at
/s/:slug.Example: pale-snow-91Behavior
The component implements intelligent auto-detection:- Slug resolution: If no
slugprop is provided, it automatically extracts the slug from URLs matching the pattern/s/:slug - Gateway URL: Uses
gatewayUrlprop, falls back toNEXT_PUBLIC_WORMKEY_GATEWAY_URLenvironment variable - Script URL construction: Builds the overlay script URL as
{gatewayUrl}/.wormkey/overlay.js?slug={slug}&v=2 - Client-side only: Only runs in browser environments (safe for SSR)
- Duplicate prevention: Ensures only one overlay script is loaded per page
The component renders
null and has no visual output. It only manages loading the overlay script, which then injects the owner control bar into the page.Environment Variables
Default gateway URL used when
gatewayUrl prop is not provided.Example: https://wormkey.runExamples
Explicit script URL
Gateway URL with auto-detected slug
/s/quiet-lime-82, the slug is automatically detected.
Explicit slug
Source
Location:packages/cli/src/overlay.tsx