Frontend frameworks
Connect browser applications through your own backend without exposing a SwitchPilot credential.
Never expose a SwitchPilot API key in browser code
There is no client-side SwitchPilot SDK. Do not place
SWITCHPILOT_API_KEY in Angular, Vue, React, Svelte, public environment variables, or browser bundles.Secure architecture
request flow
Angular / Vue / React / Svelte browser
→ GET /api/features on your own backend
→ Node.js or Python server
→ SwitchPilot SDKThe browser calls a route owned by your application. That route applies your normal authentication and authorization, evaluates the flag with the server-side SDK, and returns only the safe values the UI needs.
1. Install on the backend
Node.js backend
pnpm add @switchpilot/nodePython backend
pip install switchpilotserver .env
SWITCHPILOT_API_KEY="sp_live_your_project_key"2. Evaluate on the server
backend/features.ts
import { createSwitchPilot } from "@switchpilot/node";
const flags = createSwitchPilot({
apiKey: process.env.SWITCHPILOT_API_KEY!,
});
// Use this inside your authenticated backend route.
const newCheckout = await flags.isEnabled("new-checkout");
return { newCheckout };isEnabled() reads the local in-memory cache. A configuration change may take up to the 60-second cache TTL to appear unlessrefresh() is called manually. Read the Reliability guide.
3. Read safe values in Angular, Vue, React, or Svelte
browser feature service
const response = await fetch("/api/features");
const features = await response.json();
if (features.newCheckout) {
// Render the enabled experience.
}This browser code contains no SwitchPilot package, endpoint, or secret. Framework-specific state management can wrap the same request pattern.