All lab notes
Lab note 002ReviewNext.js · Content · Dev Tools
First Look at Velite: The New Content Layer?
A compact technical record: the context, the useful detail, and the implementation path.
Working note. Short by design, but complete enough to return to when the same problem appears again.
Velite is a lightweight, file-based content layer built on top of Zod, designed to replace complex solutions like Contentlayer (now discontinued). It turns Markdown/MDX into strongly-typed JSON data.
Why use it?
Type Safety: Uses Zod schemas to validate and type content structure (e.g., ensuring a slug is always a string).
Simple Setup: Define your content schemas in velite.config.js and run the CLI.
Agnostic: Works great with Next.js, Astro, or any React framework.
jsSnippet// velite.config.js snippetdefineCollection({ name: "Post", schema: s.object({ slug: s.slug(), title: s.string().max(99), content: s.mdx(), }),});