Open source remote configuration, feature flags, and experimentation platform.
Self-host it anywhere or use our hosted version for a fully managed experience.
Update your app's settings without redeploying. Change themes, API endpoints, copy, or any JSON configuration instantly.
Ship code when you're ready, release when you want. Control who sees what with targeting rules and percentage rollouts.
Run A/B tests to make decisions with data. Split traffic between variants and track which performs better.
Track flag evaluations, experiment exposures, and configuration fetches. Know what's happening in your apps.
| Feature | ToggleBox |
|---|---|
| Self-Hostable | Deploy on your infrastructure with full control |
| Multi-Database | DynamoDB, PostgreSQL, MySQL, MongoDB, SQLite, Cloudflare D1 |
| Multi-Platform | AWS Lambda, Cloudflare Workers, Docker, Netlify |
| Type-Safe SDKs | JavaScript, Next.js, Expo/React Native, PHP, Laravel |
| Open Source | Inspect the code, contribute, customize |
| Hosted Option | ToggleBox Cloud for zero maintenance |
- Node.js 18+
- pnpm 8.x (
npm install -g pnpm)
# Clone the repository
git clone https://github.com/ulpi-io/togglebox.git
cd togglebox
# Install dependencies
pnpm install
# Build packages
pnpm build:packages
# Configure environment
cp apps/api/.env.example apps/api/.env
# Start the API
pnpm dev:api
# Start the admin dashboard (in another terminal)
pnpm dev:adminThe API runs at http://localhost:3000 and the admin dashboard at http://localhost:3001.
For a containerized development environment with hot reload:
# Start development environment
make dev
# View all services
make status
# View logs
make logs # All services
make logs-api # API only
make logs-admin # Admin only
# Stop services
make down
# Rebuild from scratch
make rebuildAvailable Make Commands:
| Command | Description |
|---|---|
make dev |
Start development environment with hot reload |
make prod |
Start production environment |
make down |
Stop all services |
make restart |
Restart all services |
make build |
Rebuild containers (no cache) |
make rebuild |
Clean volumes and rebuild from scratch |
make logs |
View logs for all services |
make logs-api |
View API logs only |
make logs-admin |
View Admin logs only |
make status |
Show service status and access points |
make shell-api |
Open shell in API container |
make shell-admin |
Open shell in Admin container |
make test |
Run tests in API container |
make help |
Show all available commands |
Access Points (Docker):
- API: http://localhost:3000
- Admin: http://localhost:3001
- DynamoDB: http://localhost:8000
- DynamoDB Admin: http://localhost:8001
To populate the database with demo data for all example apps:
# Run the seed script (no API required - seeds directly to database)
pnpm seedThe seed script creates:
| Resource | Description |
|---|---|
| Demo Admin User | admin@togglebox.com / Parola123! |
| API Key | Full permissions for authenticated requests |
| Platforms | web, mobile, ecommerce |
| Environments | staging (web/mobile), development (ecommerce) |
| Config Parameters | theme, apiTimeout per platform |
| Feature Flags | dark-mode, new-checkout-flow, beta-features, biometric-auth |
| Experiments | checkout-test, cta-test, checkout-button-test, pricing-display-test |
All experiments are automatically started and in "running" status.
ToggleBox provides official SDKs for multiple platforms:
npm install @togglebox/sdkimport { ToggleBoxClient } from "@togglebox/sdk";
const client = new ToggleBoxClient({
platform: "web",
environment: "production",
apiUrl: "https://your-togglebox-api.com",
});
// Remote config (Tier 1)
const config = await client.getConfig();
const theme = await client.getConfigValue("theme", "light");
// Feature flag (Tier 2)
const showNewUI = await client.isFlagEnabled("new-dashboard", {
userId: "user-123",
});
if (showNewUI) {
renderNewDashboard();
}
// Experiment (Tier 3)
const assignment = await client.getVariant("checkout-experiment", {
userId: "user-123",
});
if (assignment?.variationKey === "one-click") {
renderOneClickCheckout();
}npm install @togglebox/sdk-nextjsimport {
ToggleBoxProvider,
useFlag,
useExperiment,
useConfig,
} from "@togglebox/sdk-nextjs";
// Wrap your app
<ToggleBoxProvider
platform="web"
environment="production"
apiUrl={process.env.NEXT_PUBLIC_TOGGLEBOX_URL!}
>
<App />
</ToggleBoxProvider>;
// Use in components
function PricingPage() {
const config = useConfig();
const { isEnabled } = useFlag("new-pricing");
const { getVariant } = useExperiment("pricing-test", { userId: user.id });
const [showNewPricing, setShowNewPricing] = useState(false);
const [variant, setVariant] = useState<string | null>(null);
useEffect(() => {
isEnabled().then(setShowNewPricing);
getVariant().then(setVariant);
}, [isEnabled, getVariant]);
return showNewPricing ? <NewPricing variant={variant} /> : <OldPricing />;
}npm install @togglebox/sdk-expoimport {
ToggleBoxProvider,
useConfig,
useFlags,
useToggleBox,
} from "@togglebox/sdk-expo";
// Wrap your app with offline persistence
<ToggleBoxProvider
platform="mobile"
environment="production"
apiUrl="https://your-togglebox-api.com"
persistToStorage={true}
storageTTL={86400000}
>
<App />
</ToggleBoxProvider>;
// Use in components
function HomeScreen() {
const config = useConfig();
const flags = useFlags();
const { isLoading, isOnline, refresh } = useToggleBox();
// Works offline with cached data
return <View>...</View>;
}Both example apps are kitchen sink demos with copy-paste ready code:
Full-featured Next.js 15 app demonstrating:
| Quick Start | Complete Examples |
|---|---|
| Provider Setup | Feature Toggle UI |
| useConfig Hook | A/B Test CTA Buttons |
| useFlag Hook | Config-Driven Themes |
| useExperiment Hook | SSR with Hydration |
| Event Tracking | Polling Updates |
| SSR Config Fetching |
pnpm dev:example-nextjs # http://localhost:3002React Native/Expo app demonstrating:
| Quick Start | Advanced |
|---|---|
| Provider Setup | Conversion Tracking |
| Remote Config | Offline Storage (MMKV) |
| Feature Flags | Polling & Refresh |
| Experiments | Health Check |
| Error Handling |
pnpm dev:example-expo # Expo Go or simulatorSee the Next.js Example README and Expo Example README for detailed documentation.
cd apps/api
npm install -g serverless
serverless deploy --stage productionBest with DynamoDB for serverless-native performance.
cd apps/api
npm install -g wrangler
wrangler deployUse with Cloudflare D1 for edge-first deployment.
docker build -t togglebox .
docker run -p 3000:3000 toggleboxWorks with any database backend.
Deploy on any Node.js environment with your preferred database.
| Database | Best For |
|---|---|
| DynamoDB | AWS Lambda, serverless |
| Cloudflare D1 | Cloudflare Workers, edge |
| PostgreSQL | Self-hosted, full SQL |
| MySQL | Self-hosted, enterprise |
| MongoDB | Document-oriented workloads |
| SQLite | Local development, testing |
Configure via DB_TYPE environment variable:
DB_TYPE=postgresql
DATABASE_URL=postgresql://user:pass@localhost:5432/toggleboxtogglebox/
├── apps/
│ ├── api/ # Express.js API (multi-platform)
│ ├── admin/ # Admin dashboard (Next.js)
│ ├── example-nextjs/ # Next.js example app
│ └── example-expo/ # Expo example app
├── packages/
│ ├── core/ # Core business logic
│ ├── database/ # Multi-database abstraction
│ ├── cache/ # Cache providers (CloudFront, Cloudflare)
│ ├── auth/ # Authentication (optional)
│ ├── flags/ # Feature flag logic
│ ├── experiments/ # Experimentation logic
│ ├── configs/ # Remote config logic
│ ├── stats/ # Analytics and tracking
│ ├── sdk-js/ # JavaScript SDK
│ ├── sdk-nextjs/ # Next.js SDK
│ └── sdk-expo/ # Expo SDK
└── infrastructure/ # IaC templates
Don't want to manage infrastructure? ToggleBox Cloud gives you:
- Zero maintenance - We handle hosting, scaling, and updates
- Team collaboration - Multi-user workspaces with roles
- Enterprise features - SSO, audit logs, advanced analytics
- Guaranteed uptime - SLA-backed reliability
Get started free - No credit card required.
Elastic License 2.0 (ELv2)
- Use, modify, and self-host for your organization
- Build products and services on top of it
- Distribute modified versions
Limitation: Cannot offer ToggleBox as a hosted service to third parties.
This repository is a monorepo containing all ToggleBox packages and SDKs. SDKs are automatically published to npm and Packagist via GitHub Actions workflows.
JavaScript (npm):
@togglebox/sdk- Core JavaScript SDK@togglebox/sdk-nextjs- Next.js SDK with React hooks@togglebox/sdk-expo- Expo/React Native SDK
PHP (Packagist):
togglebox/sdk- Core PHP SDKtogglebox/laravel- Laravel SDK
JavaScript SDKs (npm):
- Managed in the monorepo at
packages/sdk-js/,packages/sdk-nextjs/,packages/sdk-expo/ - Published directly from monorepo to npm
- See PUBLISHING.md for details
PHP SDKs (Packagist):
- Managed in the monorepo at
packages/sdk-php/,packages/sdk-laravel/ - Automatically synced to separate repositories via GitHub Actions on every push to
main:packages/sdk-php/→togglebox-phppackages/sdk-laravel/→togglebox-laravel
- Packagist auto-detects updates from the split repositories
- See PUBLISHING.md for details
How it works:
- Developers work in the monorepo (
packages/sdk-php/,packages/sdk-laravel/) - On push to
main, GitHub Actions automatically splits and syncs to separate repos - Packagist detects changes via GitHub webhooks and updates packages
- No manual splitting or syncing required!
Contributions welcome! See our contributing guide.
# Fork and clone
git clone https://github.com/your-username/togglebox.git
# Create a branch
git checkout -b feature/your-feature
# Make changes and test
pnpm test
pnpm lint
# Submit a PRBuilt with TypeScript, Express.js, Next.js, and pnpm. .
