Skip to content
vuefn
0.1.0 TanStack Start for Vue on Cloudflare →

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
pages/posts/$id.vue
<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>
Point at a line to see where it runs.Worker Browser Both

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:workers
  • No 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 minimal
  • src/pages/__root.vuethe html shell
  • src/pages/index.vuethe page
  • src/router.ts
  • vite.config.tsvuefn()
  • wrangler.jsoncthe Worker
<template>
  <h1>Hello, vuefn!</h1>
</template>

From zero to a page

Terminal
$ npm create vuefn@latest

┌  create-vuefn
│
◆  Project directory
│  my-app
└

The whole API

  • vuefn(options)@vuefn/core/vite
  • defineRoute({ ... })@vuefn/core
  • defineRootRoute({ ... })@vuefn/core
  • defineRootRouteWithContext()@vuefn/core
  • useAppPlugins(...plugins)@vuefn/core
  • @vuefn/core/volartsconfig.json

The CLI

  • --template minimalone page
  • --template tailwindTailwind CSS 4
  • --template d1D1 and Drizzle

Worker and browserBuild time

vite.config.ts
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

vuefn is 0.1.0. Start with a side project, and open an issue when something breaks.