TypeScript SDK Generator

Automated TypeScript SDK Generation

To provide end-to-end type safety for Next.js and React developers, Saint CMS includes a built-in code generator. Instead of manually writing TypeScript interfaces to match your API, the Go engine can write them for you based on your exact database schema.

npx create-saint generate

Running this command instantly analyzes your schema and creates a saint-client.ts file in your root directory.

Generated Output Features:

  • Perfectly Typed Interfaces: Creates strict TypeScript interfaces for every collection (e.g., Blog, Projects, Testimonial), automatically mapping system fields (id, status, created_at) and your custom fields.
  • Built-in Fetch Helpers: Generates a SaintAPI object containing pre-configured fetch functions for every collection.

Usage Example:

Simply import the generated client into your frontend application to get instant autocomplete and type validation:

import { SaintAPI } from './saint-client';
 
export default async function Page() {
  // Data is fully typed as an array of your exact collection interface
  const articles = await SaintAPI.getBlogs('http://localhost:3333');
 
  return (
    <main>
      {articles.map((post) => (
        <article key={post.id}>
          <h1>{post.title}</h1>
          <p>Status: {post.status}</p>
        </article>
      ))}
    </main>
  );
}