This template provides a modern, full-stack starter for building Vue 3 apps with a typed backend and frontend, using OpenAPI and code generation for seamless integration.
- Vue 3 — The progressive JavaScript framework for building user interfaces
- Vuetify — Material Design component framework for Vue
- Hono — Super-fast, lightweight web framework for the backend (API)
- Chanfana + openapi-ts — OpenAPI contract-first backend (Chanfana) and code generation for both backend and frontend (openapi-ts)
- TanStack Query — Powerful async state management for data fetching and caching
- Drizzle ORM — Type-safe SQL ORM for database access
- Zod — TypeScript-first schema validation
- vue-i18n — Internationalization plugin for Vue
npm install
This template uses Cloudflare D1 as the database. You must create a D1 database in your Cloudflare account.
-
Create the database using Wrangler:
npx wrangler d1 create vite-vue-openapi-template-db
This will output a
database_id
. -
Copy the generated
database_id
-
Replace
replace_with_your_database_id
inwrangler.jsonc
with your actual database ID:
npm run seedLocalD1
npm run predeploy
This project uses Chanfana to expose your API as OpenAPI, and openapi-ts to generate fully typed API clients, Zod schemas, and TanStack Query hooks from your OpenAPI spec.
npm run generate
This will:
- Generate TypeScript types and Zod schemas for your API
- Generate TanStack Query hooks for easy data fetching
- Keep your frontend and backend in sync with your API definition
npm run dev
The generated TanStack Query hooks (in src/client/@tanstack/
) make it easy to fetch and mutate data with full type safety. Example usage:
import { useQuery } from '@tanstack/vue-query';
import { getTodosOptions } from '@/client/@tanstack/vue-query.gen';
const { data, isLoading } = useQuery(getTodosOptions());
Mutations are just as easy:
import { useMutation, useQueryClient } from '@tanstack/vue-query';
import { createTodoMutation, getTodosQueryKey } from '@/client/@tanstack/vue-query.gen';
const queryClient = useQueryClient();
const { mutate } = useMutation({
...createTodoMutation(),
onSuccess: () => queryClient.invalidateQueries({ queryKey: getTodosQueryKey() }) // refetch all todos
});
Translations are managed in src/locales/
. Use the LanguageSwitcher
component to allow users to change languages at runtime.
- Define the endpoints with Chanfana and generate the OpenAPI specification with
npm run generate
. This will output the schema in the root folder underschema.json
. OpenAPI-TS then generates the client code for the frontend. - Update database schema in
server/db/schema.ts
and run migrations - Customize UI with Vuetify themes in
src/plugins/vuetify.ts
npm run dev
— Start development servernpm run build
— Build for productionnpm run generate
— Generate OpenAPI client/types/hooks based on Chanfana endpointsnpm run seedLocalD1
— Apply DB migrations locallynpm run predeploy
— Apply DB migrations remotelynpm run test
— Run tests
This template brings together the best of modern full-stack TypeScript development: