Production setup
Env vars, caching, and deployment for production.
Before you deploy, get your environment variables right, pick a caching strategy, and make sure you're handling errors.
Environment variables
The SDK and API both need two values:
| Variable | Description |
|---|---|
INVENTRA_API_KEY |
Secret server-side API key. Never expose this to the browser. |
INVENTRA_ORG_ID |
Your organization ID. Safe to expose. |
In Next.js, use a non-NEXT_PUBLIC_ prefix for the API key so it stays on the server:
# .env.production
INVENTRA_API_KEY=ivt_live_xxx
NEXT_PUBLIC_INVENTRA_ORG_ID=org_xxxAny call that needs the API key must run on the server (Server Components, Route Handlers, Server Actions). If you need client-side data, fetch it from an API route in your own app that proxies to Inventra.
Centralise your Inventra config
Put everything downstream needs — the SDK client, the site metadata, the canonical helper, and the OG theme — in one module. Instantiating the client inline in each route leaks boilerplate everywhere and makes it hard to swap config (custom fetch, dev vs prod, testing).
// packages/plugins/config.ts (consumer-facing exports)
import { Inventra } from 'inventra';
import type { OGTheme } from 'inventra/og';
import { env } from '@/env';
export const inventra = new Inventra({
apiKey: env.INVENTRA_API_KEY,
orgId: env.INVENTRA_ORG_ID,
apiUrl: env.NEXT_PUBLIC_WEBSITE_URL
});
export const site = {
url: env.NEXT_PUBLIC_WEBSITE_URL.replace(/\/$/, ''),
name: 'Acme',
description: 'We build great things.',
professional: { /* … */ },
priceRange: '$$'
} as const;
export const canonical = (p: string) =>
`${site.url}${p.startsWith('/') ? p : `/${p}`}`;
export const inventraOGTheme: OGTheme = {
/* colors, fonts, brand — see the SEO setup Functions reference */
};Every Server Component, Route Handler, and Server Action then does:
import { inventra, site, canonical, inventraOGTheme } from '@/packages/plugins/config';One file to change when the config evolves; everything else just imports the singleton. See SEO setup → Inventra config for the full source and OG images for the OG theme walkthrough.
Caching
Blog posts change on a schedule (weekly by default). Blocks change whenever you edit them in the dashboard. ISR with a one-hour revalidation window is a good starting point.
// app/blog/[slug]/page.tsx
import { inventra } from '@/packages/plugins/config';
export const revalidate = 3600; // 1 hourThe SDK exposes inventra/next helpers for this — see the Next.js SDK page.
Error handling
All SDK methods throw on HTTP errors (4xx/5xx). Wrap calls in try/catch, or let Next.js' error boundaries catch them.
try {
const post = await inventra.contents.getBySlug(slug);
return post;
} catch (error) {
// Render a not-found UI or log and rethrow
return null;
}Recommended hosting
Inventra works with any host. A common setup:
- Vercel for the website (Next.js + ISR + edge cache).
- Inventra dashboard for content management.
- Webhooks from Inventra to trigger revalidation (coming soon).
Monitoring
For now, the SDK does not ship telemetry. Use your existing observability stack (Sentry, Datadog, Vercel Analytics) and log errors from your integration code.
Next steps
- SDK installation — constructor options and sub-exports
- SEO setup — wire sitemap,
llms.txt, JSON-LD, and OG meta tags end-to-end - OG images — branded, theme-driven OG generation for every page
- Next.js integration — ISR helpers, sitemap generator, route handlers