GitHub 37
Skip to content
ViteHub is still experimental. Expect bugs and breaking changes.

Source

Read files from your project, GitHub, or your own data, and turn lists into paged API routes.

server/sources/docs.ts
import { glob } from 'vite-hub/source'

// Markdown files from your docs folder
export default glob({
  cwd: 'docs',
  include: '**/*.md',
})
server/sources/docs.ts

Ready-made readers

Load a file, a folder, or a GitHub repository through a read-only reader.

Read from any route

useSource('docs') opens a reader for server/sources/docs.ts. keys(), read(), and list() fetch files.

Bring your own data

defineSource() reads from anywhere. Give it the keys and a way to load one item. TypeScript infers the types.

Turn a list into an API route

A file in server/collections becomes a GET route. In Vue, useCollection() loads it page by page.

Filter and search a list

array() adds filters, search, and counts to an in-memory list.

Keep a list private

authorize allows only signed-in users and returns 401 or 403 to others.