Zero-dependency TypeScript SDK for the Tailscale API v2.
@ryanmoreau/tailscale-sdk- TypeScript SDK for Tailscale APIdashboard- Example dashboard application (run locally)
Configure your .npmrc to use GitHub Packages:
echo "@ryanmoreau:registry=https://npm.pkg.github.com" >> .npmrcInstall the SDK:
npm install @ryanmoreau/tailscale-sdk
# or
bun add @ryanmoreau/tailscale-sdkAuthentication: For private packages, you'll need to authenticate with GitHub Packages. Create a personal access token with read:packages scope.
import { TailscaleClient } from "@ryanmoreau/tailscale-sdk";
const client = new TailscaleClient({
apiKey: process.env.TAILSCALE_API_KEY,
tailnet: "-", // "-" for the default tailnet
});
const devices = await client.devices.list();
console.log(devices);See the SDK documentation for full API reference.
The included React dashboard demonstrates how to use the SDK with TanStack Query hooks. It provides a full UI for managing your tailnet — devices, auth keys, DNS, ACLs, and more.
bun install
cp packages/dashboard/.env.sample packages/dashboard/.env
# Edit .env with your Tailscale API key
bun run devThe dashboard ships with ready-to-use hooks that wrap the SDK's API proxy:
Devices — use-devices.ts
useDevices()— list all devices (auto-refreshes every 30s)useDevice(id)— get a single deviceuseDeviceRoutes(id)— get advertised/enabled routesuseAuthorizeDevice()— authorize or deauthorize a deviceuseSetDeviceTags()— update device tagsuseSetDeviceRoutes()— enable/disable subnet routesuseDeleteDevice()— remove a device from the tailnet
Auth Keys — use-keys.ts
useKeys()— list all auth keys (auto-refreshes every 60s)useCreateKey()— create a new auth key with capabilitiesuseDeleteKey()— revoke an auth key
DNS — use-dns.ts
useNameservers()— get global nameserversuseSearchPaths()— get DNS search pathsuseSplitDns()— get split DNS configurationuseDnsPreferences()— get MagicDNS preferences
Policy/ACLs — use-policy.ts
usePolicy()— get the current ACL policy (HuJSON)useValidatePolicy()— validate a policy without applyinguseApplyPolicyRecipe()— apply a preset ACL recipe
Webhooks — use-webhooks.ts
useWebhooks()— list all webhook endpoints
Users — use-users.ts
useUsers()— list all users in the tailnet
This is a monorepo managed with Bun workspaces.
# Install dependencies
bun install
# Run the dashboard
bun run dev
# Build the SDK
bun run build
# Run tests
bun test
# Lint code
bun run lintPackages are automatically published to GitHub Packages when a new release is created.
To publish manually:
- Update the version in
packages/tailscale/package.json - Create a new GitHub release
- The GitHub Action will automatically build and publish the package
MIT - See LICENSE for details