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

@varianta/sdk

v0.1.6

Published

Multi-framework JavaScript SDK for product customization

Readme

@varianta/sdk

Multi-framework JavaScript SDK for product customization. Provides a simple, powerful API for integrating the Customizer Editor into your web application.

Features

  • Framework Agnostic: Works with vanilla JavaScript, React, Vue, and other frameworks
  • TypeScript First: Full TypeScript support with comprehensive type definitions
  • Lightweight: ~33KB ESM, ~22KB UMD (minified + gzipped: ~9KB/~8KB)
  • Multiple Formats: UMD, ESM, and CJS builds for maximum compatibility
  • Zero Config: Works out of the box with sensible defaults
  • Event-Driven: Rich event system for monitoring editor state
  • Print-Ready: Generate high-quality proofs and print files

Installation

# npm
npm install @varianta/sdk

# yarn
yarn add @varianta/sdk

# pnpm
pnpm add @varianta/sdk

Framework-Specific Dependencies

React:

npm install @varianta/sdk react react-dom

Vue 3:

npm install @varianta/sdk vue

Quick Start

Vanilla JavaScript

import { initCustomizer } from '@varianta/sdk';

const editor = initCustomizer('#editor-container', {
  templateId: 'tshirt-001',
  theme: 'light',
  showCloseButton: false, // hide the built-in Close button
  onReady: () => {
    console.log('Editor ready!');
  },
  onChange: (design) => {
    console.log('Design changed:', design);
  },
});

// Get current design
const design = editor.getDesign();

// Finalize and generate print files
const result = await editor.finalize();
console.log('Print-ready files:', result);

React

import { Customizer, useCustomizer } from '@varianta/sdk/react';
import { useRef } from 'react';

function App() {
  const { customizerRef, undo, redo, canUndo, canRedo, finalize } = useCustomizer();

  return (
    <div style={{ width: '100vw', height: '100vh' }}>
      <Customizer
        ref={customizerRef}
        templateId="tshirt-001"
        theme="light"
        onChange={(design) => console.log('Design changed:', design)}
      />
      <div>
        <button onClick={undo} disabled={!canUndo}>Undo</button>
        <button onClick={redo} disabled={!canRedo}>Redo</button>
        <button onClick={finalize}>Finalize Design</button>
      </div>
    </div>
  );
}

Vue 3

<template>
  <div>
    <div ref="editorRef" style="width: 100%; height: 600px;" />
    <button @click="handleFinalize">Finalize Design</button>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted, onUnmounted } from 'vue';
import { initCustomizer } from '@varianta/sdk';
import type { CustomizerInstance, DesignJSON } from '@varianta/sdk';

const editorRef = ref<HTMLElement>();
let editor: CustomizerInstance | null = null;

onMounted(() => {
  if (editorRef.value) {
    editor = initCustomizer(editorRef.value, {
      templateId: 'tshirt-001',
      theme: 'light',
      onReady: () => console.log('Editor ready!'),
      onChange: (design: DesignJSON) => console.log('Design changed:', design),
    });
  }
});

onUnmounted(() => {
  editor?.destroy();
});

const handleFinalize = async () => {
  const result = await editor?.finalize();
  console.log('Finalized:', result);
};
</script>

CDN Usage (UMD)

<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.example.com/@varianta/[email protected]/dist/index.umd.js"></script>
  <link rel="stylesheet" href="https://cdn.example.com/@customizer/[email protected]/dist/customizer.css">
</head>
<body>
  <div id="editor" style="width: 100vw; height: 100vh;"></div>

  <script>
    const editor = CustomizerSDK.initCustomizer('#editor', {
      templateId: 'tshirt-001',
      onReady: () => console.log('Ready!'),
    });
  </script>
</body>
</html>

Documentation

API Overview

Core Methods

interface CustomizerInstance {
  getDesign(): DesignJSON;
  setDesign(design: DesignJSON): void;
  undo(): void;
  redo(): void;
  canUndo(): boolean;
  canRedo(): boolean;
  finalize(): Promise<FinalizeResult>;
  addTextLayer(text?: string): void;
  addImageLayer(url: string): Promise<void>;
  removeLayer(layerId: string): void;
  selectLayer(layerId: string | null): void;
  getSelectedLayerId(): string | null;
  setTheme(theme: 'light' | 'dark'): void;
  setMode(mode: 'edit' | 'preview'): void;
  destroy(): void;
}

Event System

initCustomizer('#editor', {
  templateId: 'tshirt-001',
  onReady: () => {},
  onChange: (design) => {},
  onLayerSelect: (layerId) => {},
  onLayerAdd: (layerId) => {},
  onLayerRemove: (layerId) => {},
  onLayerUpdate: (layerId) => {},
  onError: (error) => {},
  onFinalize: (result) => {},
  onClose: () => {},
  onSave: (result) => {},
  onViewChange: (viewName) => {},
});

Configuration Options

interface CustomizerOptions {
  templateId?: string;             // Template to load (required unless productId is set)
  productId?: string;              // Product ID (loads all views/templates for the product)
  apiUrl?: string;                 // Default: 'https://api.varianta.io'
  theme?: 'light' | 'dark';        // Default: 'light'
  mode?: 'edit' | 'preview';       // Default: 'edit'
  debug?: boolean;                 // Default: false
  className?: string;              // Custom CSS class
  initialDesign?: DesignJSON;      // Pre-load a design
  showCloseButton?: boolean;       // Default: true
  showSaveButton?: boolean;        // Default: true
  // ... event handlers
}

TypeScript Support

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

import type {
  CustomizerInstance,
  CustomizerOptions,
  DesignJSON,
  FinalizeResult,
  CustomizerError,
  Scene,
  Layer,
  TextLayer,
  ImageLayer,
} from '@varianta/sdk';

Browser Support

  • Chrome/Edge 90+
  • Firefox 88+
  • Safari 14+
  • Opera 76+

License

ISC

Related Packages

Support