Integration Reference
This SDK allows you to embed the Hyperswitch connector configuration directly into your React application. It uses a provider pattern to manage authentication sessions via JWTs, ensuring your API keys never leak to the client.
Repository URL: https://github.com/juspay/hyperswitch-control-center-embedded
Demo URL: https://embedded-ssr.netlify.app/
Prerequisites & Compatibility
Before you begin, ensure your environment meets the following requirements:
Runtime: Node.js (v18+)
Framework: React (v18.x - 20.x)
Hyperswitch Credentials:
API-Key(Can be generated via Control Center)Profile-ID(The specific merchant profile you are configuring)
Support:
✅ Vite
✅ Webpack
✅ Next.js
✅ Create React App
Step 1: Backend Setup(Server-Side)
Security Warning: Never expose your Hyperswitch API-Key on the frontend. You must create a backend endpoint that acts as a proxy
Frontend → requests session → Your Backend → requests token (using API Key) → Hyperswitch API
Step 1.1: Create the Token Endpoint
Create a route (e.g., /embedded/hyperswitch) in your backend application.
Required Headers for Hyperswitch Call:
api-key: Your secret API key.
X-profile-id: The specific profile ID you want the embedded component to access.
Step 2: Choose Your Integration Method
You must choose one:
Core (JavaScript Only / HTML)
React Integration
2A: HTML-JS Integration
2A.1 Install the package:
2A.2 Import the SDK in Your Application
Import (ES Module):
OR
Import (CommonJS):
2A.3 : Example app.js Implementation
2B: React Integration
2B.1 Install the package:
2B.2 Import the SDK in Your Application
2B.3 Example app.js Implementation
Key Concept: The fetchToken function is lazy. It is called:
When the component first mounts.
Automatically whenever the SDK detects the session has expired (auto-refresh).
API Reference
1. loadHyperswitch(options)
Initializes the SDK logic.
options.fetchToken () => Promise<string | undefined>
Required.
A function that retrieves a fresh JWT from your backend.
Should return the JWT string on success.
Should return undefined on failure.
2. HyperswitchProvider
Context provider that holds the authentication state.
hyperswitchInstance: The object returned by loadHyperswitch.
3. ConnectorConfiguration
The UI Component that renders the settings form.
url (string): The base URL for the Hyperswitch Dashboard API.
Sandbox: https://app.hyperswitch.io
Default: http://localhost:9000
Last updated
Was this helpful?

