React Integration
The<WormkeyOverlay /> component automatically loads the Wormkey control bar in your React or Next.js application when viewed through a wormhole URL.
Installation
Quick Start
Next.js App Router
Add the component to your root layout:Next.js Pages Router
Add to_app.tsx:
React (Vite, CRA)
Add to your root component:Props
TheWormkeyOverlay component accepts the following props:
scriptUrl
Full overlay script URL from the CLI output.
string (optional)
gatewayUrl
Gateway base URL. Use with automatic slug detection.
string (optional)Default:
process.env.NEXT_PUBLIC_WORMKEY_GATEWAY_URL
slug
Explicit wormhole slug. Auto-detected from /s/:slug URLs if omitted.
string (optional)
Configuration Approaches
- Environment Variable
- Direct Script URL
- Slug + Gateway
Set Use in your layout:The component automatically detects the slug from the URL.
NEXT_PUBLIC_WORMKEY_GATEWAY_URL in .env.local:How It Works
Auto-detect slug
If no
slug prop is provided, it reads from window.location.pathname matching /s/:slug.Local Development
For local testing withwormkey http 3000 --local:
Server-Side Rendering
The component is marked"use client" and safe for SSR frameworks. It only runs in the browser:
TypeScript
Full TypeScript support included:Related
- Overlay Helpers - Express middleware and auto-mount options
- CLI Reference - Learn about the
wormkey httpcommand