npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

togglit-sdk

v1.0.13

Published

ToggLit SDK makes it easy to fetch dynamic JSON config files from your ToggLit project environments using just a project ID and API key. Ideal for feature toggles, remote settings, A/B testing, and more — without redeploying code.

Readme

Togglit SDK

A lightweight TypeScript SDK for fetching configuration from Togglit with real-time updates and caching support.

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.

Parameters

| Parameter | Type | Required | Description | | ----------- | --------------------- | -------- | ---------------------------------------------------- | | apiKey | string | ✅ | Your Togglit API key | | projectId | string | ✅ | Your project identifier | | env | string | ✅ | Environment name (e.g., 'production', 'development') | | version | number | ❌ | Specific configuration version to fetch | | fallback | Record<string, any> | ❌ | Fallback configuration object (default: {}) |

Returns

Promise<Record<string, any>> - The configuration object or fallback if request fails

Example

import { getConfig } from "togglit-sdk";

// Basic usage
const config = await getConfig({
  apiKey: "tk_1234567890",
  projectId: "my-project",
  env: "production",
});

// With version and fallback
const config = await getConfig({
  apiKey: "tk_1234567890",
  projectId: "my-project",
  env: "production",
  version: 2,
  fallback: {
    feature_flag: false,
    api_url: "https://api.example.com",
  },
});

Features

  • Real-time Updates: Fetch the latest configuration from Togglit
  • Caching: Built-in caching for optimal performance
  • Fallback Support: Automatic fallback to default values on API failures
  • TypeScript Support: Full TypeScript support with type definitions
  • Lightweight: Minimal dependencies and small bundle size
  • Error Handling: Graceful error handling with fallback configuration

Environment Configuration

The SDK connects to your Togglit instance at https://togglit.dev/ by default. Make sure your Togglit server is running and accessible.

Error Handling

The SDK includes built-in error handling. If the API request fails, it will:

  1. Log a warning message to the console
  2. Return the provided fallback configuration
  3. Continue execution without throwing errors
const config = await getConfig({
  apiKey: "invalid-key",
  projectId: "my-project",
  env: "production",
  fallback: {
    // These values will be used if the API call fails
    enableNewFeature: false,
    maxRetries: 3,
  },
});

// config will contain the fallback values if API fails

Usage Examples

Feature Flags

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 features
}

API Configuration

const config = await getConfig({
  apiKey: process.env.TOGGLIT_API_KEY,
  projectId: "my-service",
  env: "production",
  fallback: {
    apiUrl: "https://api.fallback.com",
    timeout: 5000,
    retries: 3,
  },
});

const apiClient = new ApiClient({
  baseUrl: config.apiUrl,
  timeout: config.timeout,
  maxRetries: config.retries,
});

Environment-Specific Configuration

// Development
const devConfig = await getConfig({
  apiKey: "dev-api-key",
  projectId: "my-project",
  env: "development",
  fallback: { debugMode: true },
});

// Production
const prodConfig = await getConfig({
  apiKey: "prod-api-key",
  projectId: "my-project",
  env: "production",
  fallback: { debugMode: false },
});

TypeScript Support

The SDK is written in TypeScript and includes full type definitions:

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: Record<string, any> = await getConfig(options);

License

MIT

Support

For issues and questions, please visit our GitHub repository or contact our support team.


Made with ❤️ by the Togglit team