sdk
All apps

TypeScript SDK

Zero Deps

Type-safe client for Node.js, Bun, Deno, and Cloudflare Workers

Gallery

About

Zero-dependency, fully typed TypeScript client. Designed for edge runtimes, Cloudflare Workers, Next.js, and serverless Node.js environments with automatic exponential backoff retries.

Features

  • Edge-runtime ready (V8 Isolates, Cloudflare Workers, Bun, Deno)
  • Zero external dependencies for minimal bundle weight
  • Complete TypeScript interface definitions for all link mutations
  • Automatic token refreshing and exponential backoff retry logic

Code Quickstart

shaf.tstypescript
import { ShafClient } from "@shaf-is/sdk";

const shaf = new ShafClient({ apiKey: process.env.SHAF_API_KEY });

// Shorten with smart expiration and custom domain
const link = await shaf.links.create({
  url: "https://cloud.cloudflare.com/workers",
  slug: "cf-workers",
  maxClicks: 500,
  password: "edge-protected",
});

console.log("Shortened URL:", link.shortUrl);