Type Generation
Lucent can automatically generate TypeScript types from your collections. This is crucial for end-to-end type safety when using the REST API or the programmatic API.
Running Type Generation
While types are automatically generated when running lucent dev, you can also trigger generation manually via the CLI:
bash
# Generate types from project root
lucent typegenThis reads your lucent.config.ts and writes the inferred types to the location specified in your configuration (defaulting to ./lucent-types.ts).
Configuration
You can customize where types are generated in your lucent.config.ts:
typescript
import { defineLucentConfig } from "@codesordinatestudio/lucent-cms";
export default defineLucentConfig({
/* ... */
typegen: {
// Custom output path
output: "./src/types/lucent.ts",
},
});import type { PostSchema } from "./lucent-types";
// Use generated Zod schemas for validation const validPost = PostSchema.parse(userInput);
## Watch Mode
For development, watch for changes:
```bash
bun run typegen -- --watch