CMS
Work in progress: I have not wired every block to Sanity yet. Some have schema and Studio/UI; I add the rest over time.
Example repository: See the example repository with Sanity schemas, block registry, and UI components already wired up. Clone it to explore a full setup or use it as reference while you adapt the steps below to your project.
You can also import the data exported from the example repository to your project. Check the README.md for more details.
The blocks are open source like the rest of Flexnative. This page is just how I
set up Sanity: shared objects, the blocks array, registry, render-block,
page wiring.
Your folders, plugins, and schema habits will differ. Take the idea, then change paths and types to match your repo. Same point as on the About page: keep the shape obvious so tools (and AI) can reuse catalog examples and rebuild things in your layout.
Right now Flexnative ships Sanity wiring in the open repo. Another CMS might appear later too.
Treat the snippets as a starter layout and adjust them for your Studio and app.
Sanity Typegen: I've used Sanity
TypeGen to
generate TypeScript types from the schema. The registry and components import
types from the generated file (e.g. Blocks, Home in
sanity.types.ts). Configure and run typegen in your project per the
official
documentation.
Shared objects (optional)
Blocks that use CTA, links, etc. reuse shared objects. Example: the cta object. See Shared objects below for the list.
You need to export and include these types in your schema according to your project’s context (e.g. an objects index that re-exports cta and others).
Define a block (e.g. Grid Two Columns)
Define the blocks array (blocks.ts)
This is how I use blocks on a page: an array per category (e.g. content) referenced on the document type. When you add blocks or categories, update this file. The values in of refer to the schema type — if the type doesn’t exist in the project, the Studio will break.
Define a page type (e.g. home)
A document type like home uses the blocks array so editors can add blocks in the Studio. The field type: 'blocks' references the blocks schema defined in blocks.ts.
Block registry (UI)
When adding a new block, register it here. Import types from the generated file (e.g. Blocks from sanity.types.ts).
Render block
Blocks component
Example page
Shared objects
Shared objects are reusable schema types in the Studio. Blocks that need a call-to-action or other shared fields use these. Each object has a Schema (Studio) and a UI component that consumes data from Sanity types. Select an object below.
Schema (Studio)
The CTA object defines the schema for call-to-action fields (text, link, variant). Include it in your schema and export it according to your project’s structure.
CTA component (UI)
Component that consumes CtaType from your generated types (e.g. sanity.types.ts). Use this in blocks that have a CTA field from Sanity.