Overview
The basic workflow for Val is to: define your content schema, register your modules, and use the content in your app. This guide will walk you through creating your first Val content module.
Step 1: Create a Val module
Content in Val is defined in .val.ts files. These files contain both the schema (what fields your content has) and the initial content values.
If you used the initialization script, you should already have example files. Otherwise, create your first module:
app/page.val.ts
Understanding the code
sis the schema builder - it provides type-safe schema definitionscis the content builder - used to define and validate content modulesc.define()takes three arguments: a unique path identifier, the schema, and the initial contentThe content object must match the schema - TypeScript will catch any mismatches
Step 2: Register your module
After creating a Val module, you need to register it in val.modules.ts so Val knows about it. This file should be at the root of your project.
val.modules.ts
The def property uses a function that dynamically imports your module. This enables code splitting and better performance.
Step 3: Use content in your app
Now you can use your Val content in React components. Val provides different APIs depending on whether you're using Client or Server Components.
Client Components
For client-side rendering, use the useVal hook. This is perfect for interactive components that need client-side state.
app/page.tsx (Client Component)
Server Components
For server-side rendering (recommended for better performance), use the fetchVal function. This renders on the server and sends HTML to the client.
app/page.tsx (Server Component)
Editing your content
Once your Val module is set up and registered, you can edit the content in two ways:
Directly in code - Edit the default export in your
.val.tsfileUsing Val Studio - Visit
/valin your browser for a visual editing interface (requires running your dev server)
Val Studio provides a user-friendly interface where non-technical team members can edit content without touching code.
Next steps
Now that you have your first Val module working, you can:
Learn about rich text
Setup page routing to make it easier for content editors to create pages
Explore different schema types like arrays, images, and nested objects
Improve the UI experience with the render methods
Common issues
Module not found: Make sure your module is registered in val.modules.ts and the import path is correct.
Type errors: Your content object must match the schema exactly. Check that all required fields are present and have the correct types.
Content not updating: In development, you may need to refresh the page or restart your dev server after making changes to .val.ts files.