Skip to main content

Frameworks

Bun — Scell.io integration

@scell/sdk + native Bun fetch (zero-config)

The `@scell/sdk` v3.5.0 SDK runs natively in Bun (>= 1.1) via `bun add @scell/sdk`. Bun supports `Bun.serve()` as an ultra-fast alternative to Express: <50ms startup, native fetch (no polyfill). Env vars via `Bun.env.SCELL_API_KEY` or `process.env`. Ideal for serverless or edge APIs.

Key facts

  • Install: `bun add @scell/sdk`
  • Native `Bun.serve()`, <50ms startup
  • Native Bun fetch (HTTP/2 + keep-alive)
  • `Bun.env.SCELL_API_KEY` or `process.env`
  • Compatible with Bun 1.1+, ideal serverless/edge

Code example

import { ScellClient } from '@scell/sdk';

const scell = new ScellClient({ apiKey: Bun.env.SCELL_API_KEY! });

Bun.serve({
  port: 3000,
  async fetch(req) {
    if (req.method !== 'POST') return new Response('Method Not Allowed', { status: 405 });
    const { buyer, amount } = await req.json();
    const invoice = await scell.invoices.create({
      format: 'factur-x',
      buyer: { name: buyer, is_individual: true },
      lines: [{ description: 'Service', quantity: 1, unit_price: amount, vat_rate: 20.0 }],
    });
    return Response.json({ id: invoice.id });
  },
});

See also

Your cookie preferences

We use cookies to improve your experience. Essential cookies are always active. Cookie policy.