One .vue file
per route.
The loader, the server functions and the page live in one file. vuefn turns it into a TanStack Start route that runs on Cloudflare Workers.
npm create vuefn@latest<script lang="ts">
import { notFound } from '@tanstack/vue-router';
import { createServerFn } from '@tanstack/vue-start';
import { defineRoute } from '@vuefn/core';
import { env } from 'cloudflare:workers';
type Post = { id: string; title: string; body: string };
export const getPost = createServerFn()
.validator((id: string) => id)
.handler(async ({ data: id }) => {
const post = await env.DB.prepare('select * from posts where id = ?')
.bind(id).first<Post>();
if (!post) throw notFound();
return post;
});
export const route = defineRoute({
loader: ({ params }) => getPost({ data: params.id }),
});
</script>
<script setup lang="ts">
const post = route.useLoaderData();
</script>
<template>
<article>
<h1>{{ post.title }}</h1>
<p>{{ post.body }}</p>
</article>
</template>What you get
Server code in the page
A createServerFn in the route block runs on the Worker. The browser gets only the call.
createServerFn()Typed from the file name
useLoaderData, useParams and Link know the route, and you never write its path.
route.useParams()Cloudflare Workers
D1 and env come in through the Worker. Prerendered pages are served as static files.
cloudflare:workersNo runtime of its own
TanStack Start does the routing and the server render. vuefn only moves one block.
@vuefn/core/vite
Start from a template
The CLI asks which one you want and can install the dependencies for you.
One page that says hello. The smallest app vuefn makes.
npm create vuefn@latest my-app -- --template minimalsrc/pages/__root.vuethe html shellsrc/pages/index.vuethe pagesrc/router.tsvite.config.tsvuefn()wrangler.jsoncthe Worker
<template>
<h1>Hello, vuefn!</h1>
</template>From zero to a page
$ npm create vuefn@latest ┌ create-vuefn │ ◆ Project directory │ my-app └
The whole API
vuefn(options)@vuefn/core/vitedefineRoute({ ... })@vuefn/coredefineRootRoute({ ... })@vuefn/coredefineRootRouteWithContext()@vuefn/coreuseAppPlugins(...plugins)@vuefn/core@vuefn/core/volartsconfig.json
The CLI
--template minimalone page--template tailwindTailwind CSS 4--template d1D1 and Drizzle
Worker and browserBuild time
import { cloudflare } from '@cloudflare/vite-plugin';
import vue from '@vitejs/plugin-vue';
import { vuefn } from '@vuefn/core/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
cloudflare({ viteEnvironment: { name: 'ssr' } }),
vuefn(),
vue(),
],
});vuefn() takes the place of tanstackStart() and takes the same options. Every other option is a TanStack route or Start option. vuefn adds none of its own.
Built on, tested with
TanStack Start
~1.169 does the routing and server functions
Vue 3.5
renders the page
Vite 8
builds it
Cloudflare Workers
workerd runs in every browser test
Node with srvx
a second example app
Unit and browser tests
on every push
Node 22 and 24
packed tarballs installed in CI
Volar
types defineRoute without a path
TypeScript 6
vue-tsc 3 does not run on 7 yet
MIT
no runtime of its own