Skip to main content

Quickstart Guide

Get up and running with Superflag in your React, React Native, or CLI project in under 2 minutes.

Choose Your Platform

Installation

npm
npm install @superflag-sh/react
yarn
yarn add @superflag-sh/react
pnpm
pnpm add @superflag-sh/react
bun
bun add @superflag-sh/react

Setup

Wrap your app with SuperflagProvider:
import { SuperflagProvider } from '@superflag-sh/react'

function App() {
  return (
    <SuperflagProvider clientKey={process.env.NEXT_PUBLIC_SUPERFLAG_CLIENT_KEY}>
      <YourApp />
    </SuperflagProvider>
  )
}

Use Flags

import { useFlag } from '@superflag-sh/react'

function MyComponent() {
  const showNewFeature = useFlag('new-feature', false)

  return (
    <div>
      {showNewFeature && <NewFeature />}
    </div>
  )
}

Full React Docs

Learn more about the React SDK →

Get Your Client Key

  1. Go to your Superflag dashboard
  2. Select your app and environment
  3. Click “API Keys” in the sidebar
  4. Copy your public client key (starts with pub_)
Never use SDK keys (starting with sdk_) in client-side code. Only use public keys (pub_).

Environment Variables

React / Next.js

.env.local
NEXT_PUBLIC_SUPERFLAG_CLIENT_KEY=pub_...

React Native / Expo

.env
EXPO_PUBLIC_SUPERFLAG_CLIENT_KEY=pub_...

Next Steps