Vue
Vue 3 is the front end of Fellow applications. @fellowframework/vue renders pages over the
Inertia protocol and gives components a client typed from the server contracts.
@fellowframework/build compiles single-file components with Bun.build: no Vite, no Node.js, no Nuxt.
bunx @fellowframework/cli new my-app # web template: one module, one page
cd my-app && bun install && cp .env.example .env
bun fellow migrate && bun fellow dev
How a screen is made
| Piece | File | Role |
|---|---|---|
| Page contract | modules/<module>/routes/<name>.page.ts |
definePage: path, access, tenant, props schema, handler |
| Component | modules/<module>/pages/<Name>.vue |
Receives the validated props |
| Entry | src/main.ts |
createFellowApp({ pages }) boots Vue over Inertia |
| Generated | src/fellow.gen.ts |
pages (one lazy import per component) and api (typed client) |
fellow make:page <module>/<Path> (for example records/documents/Show) writes the contract, the component and a test. fellow dev regenerates
src/fellow.gen.ts when a contract changes and keeps component state across edits (HMR).
// src/main.ts
import { createFellowApp } from '@fellowframework/vue'
import { pages } from './fellow.gen'
createFellowApp({ pages, title: (title) => `${title} · My app` })
createFellowApp also takes layout (default layout for every page), plugins (Vue plugins) and progress
(false or { color }).
What @fellowframework/vue exports
| Export | Use |
|---|---|
createFellowApp |
Boot the application |
useAuth() |
auth, isAuthenticated, can(permission) for presentation; the server authorizes again |
useForm(api, routeId, initial, { schema, onSuccess }) |
Form bound to a route: validates with the server’s Zod schema, maps 422 issues to fields |
useQuery(api, routeId, args) |
Loads a GET route and reloads when the arguments change: data, error, loading, refresh() |
usePagination(api, routeId, { limit }) |
Offset pagination over a list route that takes limit/offset and returns { items } |
createClient, ApiError |
The typed client behind api; ApiError has code, status, requestId, fieldErrors |
subscribeChannel |
Server-Sent Events channels (see fellow docs operations) |
Head, Link, router, usePage |
Re-exported from @inertiajs/vue3 |
<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>
Help inside the application
<fellow-ask> answers questions from the application’s own docs/ and contracts, on the user’s device. Import
@fellowframework/ask/element in the page and use the tag; the build leaves fellow-* tags to the browser. See
fellow docs knowledge.
Rules the validator enforces
- Components import schemas from
@fellowframework/core/contracts(browser-safe) or from entity files, never server code (FW-ARCH-004). src/fellow.gen.tsmatches the contracts (FW-GEN-003): runfellow types, or letdev/builddo it.
Rendering
Pages render in the browser. For content that must be readable without JavaScript (documentation, landing
pages), a page declares document and can be exported as static files with fellow build --preset static:
see fellow docs pages and fellow docs adr/0018-document-and-static-export. Server-side rendering of Vue
components with hydration is not available yet.
Read next: fellow docs pages, fellow docs routes, fellow docs auth.