Pages and Vue

Fellow speaks the Inertia protocol: a page is a server contract that renders a Vue component with typed props. There is no separate API for screens, and no client-side router to keep in sync.

// modules/records/routes/documents.index.page.ts
export default definePage({
  id: 'records.documents.index',
  path: '/records/documents',
  component: 'records/documents/Index',      // modules/records/pages/documents/Index.vue
  props: z.object({ documents: z.array(documentSchema), stats: statsSchema }),
  access: { permission: 'records.document.read' },
  tenant: 'required',
  handler: async () => ({ documents: await listDocuments(), stats: defer(() => documentStats()) }),
})
  • Props are parsed through props: fields outside the schema never reach the browser.
  • defer(fn, group?) props load after the first paint, in a second request.
  • Partial reloads (router.reload({ only: ['stats'] })) run only the requested props.
  • Every page receives auth (subject, name, tenant, permissions, roles), csrfToken, errors and what app.ts’s share() returns.
  • Unauthenticated visits redirect to loginPath (set in app.ts) with ?redirect=.
  • Other errors render the fellow/Error component with the status.
  • The page object is embedded as JSON in <script type="application/json">, escaped against injection.
  • A changed version in app.ts forces a full reload (409 + X-Inertia-Location).

Content readable without JavaScript: document

Pages render in the browser, so a first visit normally returns the shell and the page object. A page whose content must be read by crawlers, agents or browsers without JavaScript declares document: the server puts its parts in the HTML of the first visit, built from the validated props.

import { definePage, escapeHtml, z } from '@fellowframework/core'

export default definePage({
  id: 'docs.topics.show',
  path: '/docs/:topic',
  component: 'docs/Topic',
  input: { params: z.object({ topic: z.string() }) },
  props: z.object({ title: z.string(), html: z.string() }),
  access: 'public',
  tenant: 'none',
  handler: ({ input }) => loadTopic(input.params.topic),
  document: ({ props }) => ({
    title: `${props.title} · Docs`,                                              // replaces <title>, escaped
    head: `<meta name="description" content="${escapeHtml(props.title)}">`,     // appended to <head>, trusted
    body: `<main><article>${props.html}</article></main>`,                       // inside <div id="app">, trusted
  }),
})
  • head and body are trusted HTML: escape every value with escapeHtml. title is escaped for you.
  • There is no hydration: the component replaces body when it mounts. Render the same content in both, for example by passing the HTML as a prop and showing it with v-html.
  • document runs only on first visits, never on Inertia navigations, and does not see deferred props.

Static export

fellow build --preset static writes the site to .output/public with no server: every page with access: 'public', tenant: 'none' and no path parameters becomes an HTML file, and the links found in what those pages render (document.body) are followed, which reaches the pages with parameters. A broken link fails the build. /docs/vue is written as docs/vue.html, so the host must serve x.html at /x (Cloudflare Pages, Netlify and GitHub Pages do; nginx needs try_files $uri $uri.html). In a static site use plain <a href> links: there is no server to answer Inertia navigations.

Vue side: @fellowframework/vue

The full guide is fellow docs vue; Astro and React are covered in fellow docs astro and fellow docs react.

// src/main.ts — `pages` comes from the generated src/fellow.gen.ts (one lazy import per page component)
import { pages } from './fellow.gen'
createFellowApp({ pages, title: (t) => `${t} · App` })
<script setup lang="ts">
import { useForm, usePagination, useAuth, Head } from '@fellowframework/vue'
import { api } from '~/src/fellow.gen'
import { documentSchema } from '~/modules/records/entities/document'

const { can } = useAuth()
const list = usePagination(api, 'records.documents.list', { limit: 20 })
const form = useForm(api, 'records.documents.create', { title: '' }, { schema: documentSchema.pick({ title: true }), onSuccess: () => list.refresh() })
</script>
  • src/fellow.gen.ts (fellow types, also run by dev/build, checked by fellow check as FW-GEN-003) types every route’s params, query, body and response from the server contracts.
  • useForm validates with the same Zod schema as the server and maps server 422 issues to fields.
  • api.call(id, args) throws ApiError with code, status, requestId and fieldErrors.
  • Components may import schemas from @fellowframework/core/contracts (browser-safe) and never server code (FW-ARCH-004).