ToggLit SDK

A lightweight TypeScript SDK for fetching configuration from Togglit.

Installation

npm install togglit-sdk
yarn add togglit-sdk
pnpm add togglit-sdk

Quick Start

import { getConfig } from 'togglit-sdk';

const config = await getConfig({
  apiKey: 'your-api-key',
  projectId: 'your-project-id',
  env: 'production',
  version: 1
});

console.log(config);

API Reference: getConfig(options)

Fetches configuration from Togglit with automatic fallback support.

ParameterTypeRequiredDescription
apiKeystringYour Togglit API key
projectIdstringYour project identifier
envstringEnvironment name (e.g. 'production')
versionnumberOptional config version
fallbackobjectFallback config object

Feature Flags & Fallbacks

const config = await getConfig({
  apiKey: process.env.TOGGLIT_API_KEY,
  projectId: 'my-app',
  env: process.env.NODE_ENV,
  fallback: {
    enableBetaFeatures: false,
    showMaintenanceMode: false
  }
});

if (config.enableBetaFeatures) {
  // Show beta UI
}

Error Handling

If the API call fails, the SDK will log a warning, use your fallback, and continue.

const config = await getConfig({
  apiKey: 'invalid-key',
  projectId: 'my-project',
  env: 'production',
  fallback: {
    enableNewFeature: false,
    maxRetries: 3
  }
});

// fallback config is used if request fails

TypeScript Usage

import { getConfig, GetConfigOptions } from 'togglit-sdk';

const options: GetConfigOptions = {
  apiKey: 'your-api-key',
  projectId: 'your-project-id',
  env: 'production',
  version: 1,
  fallback: {
    feature1: true,
    feature2: false
  }
};

const config = await getConfig(options);
Made with ❤️ By @gunaa_dev