Skip to content

Frontend Integration

Porulle is a backend framework. Your storefront calls its REST API. This section covers the established patterns for wiring the API into a TypeScript frontend with full type safety end-to-end.

Porulle exposes its API at /api/* (mounted by createServer). Every route is documented in the OpenAPI spec served at /api/doc. Generate TypeScript types from that spec, then call the API through @porulle/sdk for end-to-end type safety:

Terminal window
bunx openapi-typescript http://localhost:4000/api/doc -o src/generated/api-types.ts
import { createClient } from "@porulle/sdk";
import type { paths } from "./generated/api-types";
const client = createClient<paths>({
baseUrl: process.env.NEXT_PUBLIC_API_URL!,
});
const { data } = await client.GET("/api/catalog/entities", {
params: { query: { type: "product", limit: 10 } },
});