Skip to Content

Vard SDK Documentation

Welcome to the Vard SDK documentation.

This section contains comprehensive guides, API references, and code examples to help you integrate the schema-first Vard content layer into your Next.js applications.

Getting Started

npm install @vard/sdk

Schema Composition

Vard SDK allows you to define your content schema in multiple files and merge them together at the call-site. This is particularly useful for large applications where content is co-located with features or pages.

Defining Fragments with v.schema()

Use v.schema() to define a partial schema. These fragments are type-safe and can be exported from any file.

// app/therapists/schema.ts import { v } from "@vard/sdk"; export const therapistSchema = v.schema({ therapists: v.collection({ name: v.string("New Therapist"), photo: v.image("/default-avatar.jpg"), bio: v.richtext(), }), });

Extending the Client with vard.extend()

The vard.extend() method allows you to merge one or more schema fragments into your main client. It returns a new client instance scoped with the merged types, while sharing the same underlying store and cache.

// app/therapists/page.tsx import { vard } from "@/lib/vard"; import { therapistSchema } from "./schema"; export default async function Page() { // Extend the global client with the local schema fragment const client = vard.extend(therapistSchema); // Type-safe fetching of both global and extended content const { global, therapists } = await client.get(); return ( <div> <h1>{global.siteName}</h1> <ul> {therapists.map(t => ( <li key={t.name}>{t.name}</li> ))} </ul> </div> ); }

Why use Schema Composition?

  1. Modularity: Keep your schema definitions close to where they are used.
  2. Type Safety: Get full autocomplete and type checking for the merged schema.
  3. Performance: Vard handles memoization and prefetching internally, regardless of how many times you extend the client.

Vard SDK Documentation | Vard