Astro
@fellowframework/astro connects an Astro site to Fellow: the framework documentation
becomes a content collection, and Fellow routes can be served from Astro endpoints. Astro renders the pages;
Fellow keeps the contracts.
bun add @fellowframework/astro @fellowframework/core
Run Astro on Bun (bunx --bun astro dev, bunx --bun astro build): the Fellow packages ship TypeScript and do
not run on Node.js.
The reference example is https://fellow.run itself (source: https://github.com/FellowFramework/fellow.run):
an Astro site whose /docs pages come from the docs/ directory of the installed @fellowframework/core,
deployed as static files on Cloudflare Workers.
The integration
// astro.config.ts
import fellowAstro from '@fellowframework/astro'
import { defineConfig } from 'astro/config'
export default defineConfig({ integrations: [fellowAstro()] })
It adds the virtual module virtual:fellow, which exports version: the installed @fellowframework/core.
For its types, add /// <reference types="@fellowframework/astro/virtual" /> to src/env.d.ts.
The documentation as a content collection
// src/content.config.ts
import { fellowDocs } from '@fellowframework/astro'
import { defineCollection } from 'astro:content'
export const collections = { docs: defineCollection({ loader: fellowDocs() }) }
Each entry is one document of the installed version:
| Field | Content |
|---|---|
id |
The topic: routes, adr/0017-bun-nitro-without-vite |
data.title, data.description |
From the document’s heading and first paragraph |
data.group, data.order |
Navigation group (Start, Build, …, Decisions) and reading order |
body |
The Markdown, with links between documents and fellow docs <topic> mentions pointing at site pages |
| rendered HTML | Through Astro’s Markdown pipeline: render(entry) gives Content and headings |
fellowDocs({ base, repository, root }): base is the URL prefix of the pages (default /docs), repository
is where links to files outside docs/ point, root is where node_modules is looked up (default: the Astro
project). Upgrading @fellowframework/core is what updates the pages; a new document appears without any change
in the site. @fellowframework/astro/docs exports the same data without Astro (docsTopics, docsNavigation,
readTopic, linkTopic, frameworkVersion) for scripts.
Fellow routes as Astro endpoints
// src/pages/api/documents.ts
import { fellowEndpoint } from '@fellowframework/astro'
import listDocuments from '~/modules/records/routes/documents.list'
export const prerender = false
export const GET = fellowEndpoint(listDocuments)
The route runs through the whole Fellow pipeline: identity, permission, tenant, input and output validation
(see fellow docs routes). Path parameters come from Astro’s params; the file name decides the URL, so keep it
equal to the contract’s path.
Ask and search on the site
<fellow-ask> from @fellowframework/ask works in an Astro page: import @fellowframework/ask/element from a
<script> and point source at a Markdown file of the site (fellow.run uses its /llms-full.txt). See
fellow docs knowledge.
Limits
- Endpoints need Bun.
fellowEndpointruns@fellowframework/core, which uses Bun APIs: it works when the Astro server runs on Bun, not on Node.js adapters and not inside Cloudflare Workers. A static Astro site (the documentation collection, prerendered pages) can be hosted anywhere. - No Astro pages from
definePage. Pages declared withdefinePagerender Vue components (fellow docs vue); in an Astro site, write.astropages and call routes. - No generated client for islands yet. The typed client of
src/fellow.gen.tstargets@fellowframework/vue; from an island, call the endpoints withfetchand share Zod schemas through@fellowframework/core/contracts. - Same origin. Fellow ships no CORS middleware: serve the islands and the endpoints from one origin.