Frameworks
Next.js 16 — Scell.io integration
Server Actions + @scell/sdk server-side only
The `@scell/sdk` v3.5.0 SDK integrates with Next.js 16 via Server Actions ('use server') or Route Handlers (`/app/api/*/route.ts`). Important: NEVER expose `sk_*` key client-side (no `NEXT_PUBLIC_`). For client-side widgets, use only `pk_*` (publishable key). Compatible with Cache Components and Turbopack.
Key facts
- Server Actions with `'use server'` directive
- NEVER `NEXT_PUBLIC_SCELL_API_KEY` (secret leak)
- Route Handlers: `/app/api/invoices/route.ts`
- `import 'server-only'` to block client side
- Compatible with Next.js 16, App Router, Cache Components
Code example
// app/actions/create-invoice.ts
'use server';
import 'server-only';
import { ScellClient } from '@scell/sdk';
import { revalidatePath } from 'next/cache';
const scell = new ScellClient({ apiKey: process.env.SCELL_API_KEY! });
export async function createInvoiceAction(formData: FormData) {
const invoice = await scell.invoices.create({
format: 'factur-x',
buyer: { name: formData.get('buyer') as string, is_individual: true },
lines: [{ description: 'Service', quantity: 1, unit_price: Number(formData.get('amount')), vat_rate: 20.0 }],
});
revalidatePath('/invoices');
return { id: invoice.id };
}