Learn how to use Switchyy as a feature flag system for your applications. Control what features users see without deploying new code.
Feature flags in Switchyy work through our mode system. While traditional feature flag services give you boolean toggles, Switchyyprovides mode-based control that's perfect for common use cases like maintenance windows, staged rollouts, and emergency shutdowns.
When your app loads, it connects to Switchyy and receives the current mode for your project. Based on this mode, you can:
Add our script to your HTML and we'll handle everything automatically:
<script
src="https://switchyy.vercel.app/switchy.js?key=YOUR_KEY&project=YOUR_ID"
></script>For more control, call our decision API directly:
const response = await fetch(
'https://switchyy.vercel.app/api/v1/decide?projectId=YOUR_ID&key=YOUR_KEY'
);
const { data } = await response.json();
if (data.mode === 'maintenance') {
// Show maintenance page
} else if (data.mode === 'custom') {
// Handle custom mode with data.message, data.redirect
} else {
// Normal operation (live mode)
}When you change a mode in the dashboard, all connected clients receive the update instantly via Server-Sent Events. No polling required.
Pro Tip
Our script handles SSE connections automatically. If you're using the API directly, connect to /api/v1/events/[projectId] for real-time updates.