Table of Contents
Getting started
Create your first Val content file
Content in Val is always defined in `.val.ts` (or `.js`) files.
NOTE: the init script will generate an example Val content file (unless you opt out of it).
Requirements
Val content files are evaluated by Val, therefore they need to abide a set of requirements.
If you use the eslint plugins these requirements will be enforced. You can also validate val files using the @valbuild/cli: `npx -p @valbuild/cli val validate`.
they must export a default content definition (`c.define`) where the first argument equals the path of the file relative to the `val.config` file; and
they must be declared in the `val.modules` file; and
they must have a default export that is `c.define`; and
they can only import Val related files or types (using `import type { MyType } from "./otherModule.ts"`)
Val content file example
The val.modules file
Once you have created your Val content file, it must be declared in the `val.modules.ts` (or `.js`) file in the project root folder.
Using Val in Client Components
In client components you can access your content with the `useVal` hook:
Using Val in React Server Components
In React Server components you can access your content with the `fetchVal` function: