Skip to content

TypeScript framework for building JavaScript SDKs with functional plugin architecture

License

Notifications You must be signed in to change notification settings

prosdevlab/sdk-kit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

SDK Kit

npm version npm downloads License: MIT TypeScript CI PRs Welcome Code of Conduct

Modern TypeScript framework for building JavaScript SDKs

SDK Kit provides a composable, plugin-based architecture for building type-safe, tree-shakeable JavaScript SDKs. Built with TypeScript and designed for modern development workflows, it offers the flexibility of a minimal core with the power of capability-based plugins.

About: SDK Kit started as a personal learning project during winter break 2025, exploring production SDK architecture patterns. Now maintained at prosdevlab for continued development.

Why SDK Kit?

Building a JavaScript SDK shouldn't mean starting from scratch every time. SDK Kit provides the foundational patterns and architecture that successful SDKs need:

  • Plugin Architecture - Functional, composable plugins with capability injection
  • Type-Safe - Full TypeScript support with inference and strict types
  • Tree-Shakeable - Build-time plugin exclusion for optimal bundle sizes
  • Framework-Agnostic - Works in vanilla JS, React, Vue, Svelte, or any framework
  • Event-Driven - Built-in event system with wildcard pattern matching
  • Zero Dependencies - Minimal footprint, maximum flexibility
  • Developer Experience - Intuitive API inspired by proven SDK patterns

Project Status

πŸš€ Phase 2 Complete! Essential plugins ready for production use.

Core Framework:

  • βœ… Core SDK with plugin system
  • βœ… 5 capabilities (Emitter, Config, Namespace, Expose, Requirer)
  • βœ… 550+ tests with 98%+ coverage
  • βœ… Full TypeScript support

Essential Plugins:

  • βœ… Storage (localStorage/sessionStorage/cookies/memory)
  • βœ… Context (browser/device detection)
  • βœ… Poll (async resource polling)
  • βœ… Queue (batching & persistence)
  • βœ… Transport (fetch/beacon/pixel/XHR)
  • βœ… Consent (OneTrust/CookieBot)

See ROADMAP.md for what's next.

Project Structure

sdk-kit/
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ core/              # @prosdevlab/sdk-kit - Core SDK framework βœ…
β”‚   β”œβ”€β”€ plugins/           # @prosdevlab/sdk-kit-plugins - Essential plugins βœ…
β”‚   └── testing/           # @prosdevlab/sdk-kit-testing - Testing utilities βœ…
β”œβ”€β”€ examples/
β”‚   └── minimal-sdk/       # Working example SDK βœ…
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ integration/       # Integration tests βœ…
β”‚   └── e2e/              # End-to-end tests βœ…
└── specs/                 # Feature specifications

Getting Started

Installation

Install SDK Kit from npm:

npm install @prosdevlab/sdk-kit
# or
yarn add @prosdevlab/sdk-kit
# or
pnpm add @prosdevlab/sdk-kit

Install with plugins:

npm install @prosdevlab/sdk-kit @prosdevlab/sdk-kit-plugins

Quick Start

import { SDK } from '@prosdevlab/sdk-kit';
import { storagePlugin } from '@prosdevlab/sdk-kit-plugins/storage';

const sdk = new SDK({
  name: 'my-sdk',
  version: '1.0.0'
});

sdk.use(storagePlugin);
await sdk.init();

// Use storage
sdk.storage.set('key', 'value');

Development Setup

For contributing or building from source:

Development Setup

Prerequisites:

  • Node.js (v22 LTS or higher)
  • pnpm (v9 or higher) Prerequisites:
  • Node.js (v22 LTS or higher)
  • pnpm (v9 or higher)

Clone and build:

# Clone the repository
git clone https://github.com/prosdevlab/sdk-kit.git
cd sdk-kit

# Install dependencies
pnpm install

# Build all packages
pnpm build

## Usage Examples

### Basic SDK

See the [minimal-sdk example](./examples/minimal-sdk) for a complete working SDK.

```typescript
import { SDK } from '@prosdevlab/sdk-kit';

// Create a simple plugin
function myPlugin(plugin, instance, config) {
  plugin.ns('my');
  plugin.defaults({ my: { setting: 'value' } });
  
  plugin.expose({
    greet(name) {
      plugin.emit('greeting', { name });
      return `Hello, ${name}!`;
    }
  });
  
  instance.on('sdk:ready', () => {
    console.log('SDK ready!');
  });
}

// Use the SDK
const sdk = new SDK({ my: { setting: 'custom' } });
sdk.use(myPlugin);
sdk.init();

sdk.greet('World'); // "Hello, World!"

Core Concepts

Functional Plugins

Plugins are functions that receive capabilities and compose functionality:

export default function myPlugin(plugin, instance, config) {
  plugin.ns('my.plugin');
  plugin.defaults({ my: { setting: 'default' } });
  
  plugin.expose({
    myMethod() {
      plugin.emit('my-event', { data: 'value' });
    }
  });
  
  instance.on('sdk:ready', () => {
    console.log('SDK initialized');
  });
}

Capability Injection

Plugins receive only the capabilities they need, enabling explicit dependency management and better tree-shaking:

interface Plugin extends Emitter, Defaulter, Namespaced, Exposer {}

Build-Time Optimization

Conditionally include plugins at build time for optimal bundle sizes:

// Only include what you need
if (!PLUGIN_EXCLUDED_STORAGE) {
  sdk.use(storagePlugin);
}

Documentation

Comprehensive guide for building SDK Kit plugins, covering:

  • Plugin Types - Storage-like, collectors, utilities, and orchestration plugins
  • Design Patterns - Capability injection, lazy initialization, graceful degradation
  • Testing Strategies - Unit tests, integration tests, and coverage targets
  • Best Practices - From 6 production plugins in the essential plugins package
  • Tier 1 vs Tier 2 - When to build generic vs. company-specific plugins

Perfect for developers building custom plugins or contributing to the core plugin library.

Development Workflow

Running Tests

# Run all tests (unit + integration)
pnpm test

# Run only unit tests
pnpm test:unit

# Run only integration tests
pnpm test:integration

# Run tests in watch mode
pnpm test:watch

# Run with coverage
pnpm test:coverage

Linting and Formatting

# Lint all packages
pnpm lint

# Format all packages
pnpm format

Building

# Build all packages
pnpm build

# Build a specific package
pnpm -F "@prosdevlab/sdk-kit" build

# Watch mode for development
pnpm -F "@prosdevlab/sdk-kit" dev

Type Checking

# Type check all packages
pnpm typecheck

Use Cases

  • Analytics SDKs - Event tracking, session management, user identification
  • Personalization SDKs - A/B testing, feature flags, dynamic content
  • Communication SDKs - Chat, notifications, webhooks
  • Data Collection SDKs - Form handling, validation, submission
  • Integration SDKs - Third-party API wrappers with local state

Architecture

SDK Kit is designed with the following principles:

  1. Composable - Build complex SDKs from simple, focused plugins
  2. Type-Safe - Catch errors at compile time, not runtime
  3. Efficient - Ship only what's needed with automatic tree-shaking
  4. Flexible - Work with any framework or none at all
  5. Testable - Isolated plugins are easy to test and maintain

Packages

Core SDK framework with plugin system, event emitter, and configuration management.

Install: npm install @prosdevlab/sdk-kit
Status: βœ… Published - v0.1.0
Coverage: 98.97% (192 unit tests)

Essential plugins for common SDK functionality (storage, context, poll, queue, transport, consent).

Install: npm install @prosdevlab/sdk-kit-plugins
Status: βœ… Published - v0.1.0
Coverage: 95%+ (350+ unit tests)

@prosdevlab/sdk-kit-testing

Testing utilities and mocks for building robust tests.

Status: 🚧 In Development - Not yet published

Examples

A complete working example demonstrating:

  • Plugin registration and lifecycle
  • Configuration management
  • Event handling
  • Public API exposure
  • Runtime verification tests

Roadmap

See our ROADMAP.md for detailed development plans and timelines.

Contributing

We welcome contributions! Here's how to get involved:

Our workflow follows a spec-driven approach where detailed specifications live in the specs/ directory, and GitHub issues are used for tracking progress.

Making Changes

  1. Create a new branch

    git checkout -b feature/my-feature
  2. Make your changes

  3. Commit your changes using conventional commits

    git commit -m "feat: add new feature"
  4. Add a changeset to document your changes

    pnpm changeset
  5. Push your branch and create a pull request

License

MIT Β© prosdevlab

About

TypeScript framework for building JavaScript SDKs with functional plugin architecture

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published