Frameworks
Nuxt 3 — Scell.io integration
Server route + client-side composable
The `@scell/sdk` v3.5.0 SDK integrates with Nuxt 3 via server routes (`/server/api/invoices.post.ts`) where the `sk_*` key stays secure. Client-side, create a `useScellInvoice()` composable that calls the server route via `$fetch`. Configure via `nuxt.config.ts` with `runtimeConfig.scellApiKey` (private) and `runtimeConfig.public.scellPublishableKey`.
Key facts
- Server route `/server/api/invoices.post.ts`
- `runtimeConfig.scellApiKey` private (never public)
- Client-side `useScellInvoice()` composable
- `$fetch` to call the server route
- Compatible with Nuxt 3 and 4 (Nitro)
Code example
// server/api/invoices.post.ts
import { ScellClient } from '@scell/sdk';
export default defineEventHandler(async (event) => {
const config = useRuntimeConfig();
const body = await readBody(event);
const scell = new ScellClient({ apiKey: config.scellApiKey });
return await scell.invoices.create({
format: 'factur-x',
buyer: { name: body.buyer, is_individual: true },
lines: [{ description: body.label, quantity: 1, unit_price: body.amount, vat_rate: 20.0 }],
});
});