Skip to Content
SdkTypeScript

TypeScript

The SDK is written in TypeScript and provides full type inference for your content schema.

Inferred return types

When you pass a schema to vard.define() or vard.get(), the return type is automatically inferred:

const content = vard.define({ hero: { title: v.string("Welcome"), // → string photo: v.image(), // → string showBanner: v.boolean(false), // → boolean }, team: v.collection({ name: v.string(), // → string photo: v.image(), // → string }), }); // TypeScript knows: content.hero.title // string content.hero.showBanner // boolean content.team // Array<{ name: string; photo: string }> content.team[0].name // string

No as casts. No manual type declarations. The types come directly from your schema.

The InferSchema utility type

Use InferSchema to extract the TypeScript type for a schema and use it in props or elsewhere:

import { type InferSchema } from "@vard-app/sdk"; import { v } from "@vard-app/sdk"; const heroSchema = v.schema({ hero: { title: v.string(), photo: v.image(), }, }); type HeroContent = InferSchema<typeof heroSchema>; // { hero: { title: string; photo: string } }

IDE autocomplete

Because types are inferred at compile time, you get full autocomplete in VS Code and any TypeScript-aware editor. Accessing a field that doesn’t exist in your schema is a type error.

content.hero.nonexistent // TS error: Property 'nonexistent' does not exist

Strict null handling

Fields always return a value — either the client-saved value or your default. This means field access is never undefined for fields with defaults. If you declare a field with no default (v.string()), the fallback is an empty string "".

Type-checking your schema on build

The SDK validates your schema structure at runtime during the build scan. If you pass something invalid (e.g. a nested non-field value), you’ll see a warning in your build output.

Last updated on
Vard SDK Documentation