View

ReferenceSchema API

s.view()

Show another module from this one, as a row that leads there, without copying its content.

Use it for

  • A page that shows a shared list, like the team or the products
  • Reaching a module kept out of the menu from the one page it belongs to

Reference

s.view(otherVal)

schema

Shows another module as part of this one. The value is a pointer, { view: "/other.val.ts" }, and nothing else: the module it names keeps its own content, validation and history. In the Studio it is a row that opens that module.

Reading it with useVal or fetchVal gives you the content of the module it points to. Views cannot form a cycle.

In Val Studio

Example

A page that shows the team

app/people/page.val.ts
import employeesVal from "@/content/employees.val";

const schema = s.object({
  title: s.string(),
  people: s.view(employeesVal),
});

export default c.define("/app/people/page.val.ts", schema, {
  title: "Our people",
  people: { view: "/content/employees.val.ts" },
});
See alsokeyof