Skip to Content
Apso is in public beta. Get started
GuidesFrontendOverview

Connect a frontend

Every Apso backend exposes a standard REST API. JavaScript and TypeScript applications can also use @apso/sdk for fluent queries and mutations.

Request lifecycleOne request, with every backend boundary visible.
Authenticated
  1. 01ClientServer component, mobile app, or service
  2. 02SDK or RESTTyped operation and validated payload
  3. 03IdentitySession, JWT, or API key context
  4. 04Tenant scopeAuthorization and row boundary
  5. 05ServiceGenerated route, product logic, and database
Keep privileged credentials on the server and pass only verified identity and tenant context into the generated service.

Choose a connection pattern

PatternUse it whenCredential location
Server-side SDKNext.js BFF, server-rendered app, worker, or trusted backendServer environment variables
Browser or mobile RESTThe user has an end-user token and the API permits the client originSecure cookie or platform credential storage
Route proxyThe frontend needs a narrow API and service credentials must stay privateProxy server only

Keep an Apso service API key on the server. Do not place it in NEXT_PUBLIC_*, VITE_*, a mobile bundle, or browser storage.

Framework guides

Server-side SDK setup

npm install @apso/sdk
lib/apso.ts
import { ApsoClientFactory } from '@apso/sdk'; export const apso = ApsoClientFactory.getClient({ baseURL: process.env.APSO_API_URL!, apiKey: process.env.APSO_API_KEY!, });
services/projects.ts
import { apso } from '../lib/apso'; export function listActiveProjects() { return apso.entity('Projects') .where({ status: { $eq: 'Active' } }) .orderBy({ created_at: 'DESC' }) .findMany(); }

Direct REST request

Use direct HTTP when the client has an end-user access token:

const response = await fetch(`${API_URL}/Project?limit=20`, { headers: { Authorization: `Bearer ${accessToken}`, }, }); if (!response.ok) { throw new Error(`Project request failed: ${response.status}`); } const projects = await response.json();

Before you connect

  1. Confirm the API base URL and health endpoint.
  2. Choose service API keys for trusted servers or end-user tokens for clients.
  3. Configure CORS for each browser origin that can reach the API.
  4. Verify tenant context is derived from a trusted identity claim or server-side lookup.
  5. Handle 401, 403, 404, 409, 422, and 5xx responses explicitly.
Last updated on