Skip to main content

Install

pnpm add @supaproxy/sdk
# or
npm install @supaproxy/sdk
Requirements:
  • Node.js 22+ (or any environment with fetch)
  • TypeScript 5+ (optional but recommended)

Configure

Simple (base URL only)

import { SupaProxyClient } from '@supaproxy/sdk';

const client = new SupaProxyClient('http://localhost:3001');

Full options

const client = new SupaProxyClient({
  baseUrl: 'http://localhost:3001',
  credentials: 'include',  // default -- sends cookies
  headers: {
    Cookie: 'supaproxy_session=YOUR_JWT'  // for server-side usage
  }
});

Options

OptionTypeDefaultDescription
baseUrlstringRequiredAPI server URL
credentialsstring'include'Fetch credentials mode
headersobject{}Custom headers for every request

Browser usage

In the browser, cookies are handled automatically. The SDK sends credentials: 'include' so the session cookie is attached to every request.
const client = new SupaProxyClient('http://localhost:3001');
await client.auth.login({ email: 'jane@acme.com', password: 'securepass' });
// Session cookie is now set -- all subsequent requests are authenticated

Server-side usage

For server-side rendering (e.g. Astro SSR), forward the cookie from the incoming request:
const cookie = Astro.request.headers.get('cookie') || '';
const client = new SupaProxyClient({
  baseUrl: 'http://localhost:3001',
  headers: { Cookie: cookie }
});