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

@leash/sdk

v0.4.4

Published

TypeScript SDK for Leash platform - authentication and environment management

Readme

Leash SDK

TypeScript SDK for the Leash platform. Works with any JavaScript/TypeScript framework — Next.js, Express, Koa, Hono, Fastify, plain Node.js.

Install

npm install @leash/sdk

Entry Points

| Import | Use case | Requires | |--------|----------|----------| | @leash/sdk | React hooks (useLeashAuth, useLeashEnv, LeashProvider) | React | | @leash/sdk/server | Server auth (getLeashUser, isAuthenticated) | Nothing — works with any framework | | @leash/sdk/middleware | Next.js route protection (leashMiddleware) | Next.js | | @leash/sdk/integrations | API client (LeashIntegrations, getIntegrations) | Nothing | | @leash/sdk/integrations/react | React hooks for integrations (useIntegrations, useIntegrationStatus) | React | | @leash/sdk/integrations/mcp | MCP server config helpers | Nothing |

Quick Start

React (Next.js) — client auth

// app/providers.tsx
'use client'
import { LeashProvider } from '@leash/sdk'

export default function Providers({ children }: { children: React.ReactNode }) {
  return <LeashProvider>{children}</LeashProvider>
}

// app/layout.tsx
import Providers from './providers'

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return <html><body><Providers>{children}</Providers></body></html>
}

// app/page.tsx
'use client'
import { useLeashAuth, useLeashEnv } from '@leash/sdk'

export default function Home() {
  const { user, isLoading, error } = useLeashAuth()
  const env = useLeashEnv()

  if (isLoading) return <div>Loading...</div>
  if (error) return <div>{error.message}</div>
  if (!user) return <div>Not authenticated</div>

  return <div>Welcome {user.name} — App: {env.LEASH_APP_ID}</div>
}

Express — server auth

import express from 'express'
import { getLeashUser } from '@leash/sdk/server'

const app = express()

app.get('/me', (req, res) => {
  try {
    const user = getLeashUser(req)
    res.json({ user })
  } catch {
    res.status(401).json({ error: 'Not authenticated' })
  }
})

app.listen(process.env.PORT || 3000)

Next.js API route — server auth

import { getLeashUser } from '@leash/sdk/server'
import { NextRequest, NextResponse } from 'next/server'

export async function GET(req: NextRequest) {
  const user = getLeashUser(req)
  return NextResponse.json({ user })
}

Next.js middleware — route protection

// middleware.ts
import { leashMiddleware } from '@leash/sdk/middleware'

export const middleware = leashMiddleware({
  publicRoutes: ['/login', '/about'],
  redirectTo: '/login'
})

export const config = {
  matcher: ['/((?!_next/static|_next/image|favicon.ico).*)']
}

Integrations — server-side

import { LeashIntegrations } from '@leash/sdk/integrations'

const integrations = new LeashIntegrations({
  apiKey: process.env.LEASH_API_KEY,
})

const messages = await integrations.gmail.listMessages({ maxResults: 5 })
const env = await integrations.getEnv()

Integrations — React hooks

import { useIntegrations, useIntegrationStatus } from '@leash/sdk/integrations/react'

function Dashboard() {
  const integrations = useIntegrations()
  const { isConnected, getConnectUrl } = useIntegrationStatus()

  if (!isConnected('gmail')) {
    return <a href={getConnectUrl('gmail')}>Connect Gmail</a>
  }

  // Use integrations.gmail.listMessages(), etc.
}

Server Auth — Framework Compatibility

getLeashUser(req) works with any request object that carries cookies:

  • Next.jsreq.cookies.get() (NextRequest)
  • Expressreq.cookies (with cookie-parser) or req.headers.cookie
  • Koactx.cookies or ctx.headers.cookie
  • Honoreq.headers.cookie
  • Fastifyreq.headers.cookie
  • Plain Node.jsreq.headers.cookie (IncomingMessage)

No framework-specific dependencies. Just reads the leash-auth cookie from wherever it lives.

Environment Variables

Server-side (set in dashboard, injected at deploy)

  • LEASH_JWT_SECRET — for JWT verification (optional, decodes without it)

Runtime values (auto-injected by platform)

  • LEASH_USER_ID
  • LEASH_USER_EMAIL
  • LEASH_APP_ID
  • SUPABASE_URL
  • SUPABASE_KEY

Testing

npm test

Build

npm run build

License

Apache-2.0