Vue Start
TanStack Start provides full support for Vue 3, enabling you to build type-safe, full-stack applications with Vue’s Composition API.Overview
Vue Start combines:- Vue 3 - Progressive JavaScript framework with Composition API
- TanStack Router - Type-safe routing with search params
- TanStack Start - Server functions and full-stack capabilities
Installation
Server Functions
Create server functions withcreateServerFn:
Using in Route Loaders
POST Mutations
useServerFn Composable
UseuseServerFn to call server functions from components with automatic redirect handling:
Components
StartClient
The root client component for Vue applications:StartServer
The root server component for SSR:Routing
File-Based Routes
Organize routes in thesrc/routes directory:
Root Route
Dynamic Routes
Composition API
Refs and Reactive
Vue’s reactivity works seamlessly with server functions:Computed Properties
Data Loading
Deferred Loading
Forms
Progressive Enhancement
Form Validation
Middleware
Authentication Middleware
Client-Only Code
Mark browser-only modules:Server-Only Code
Mark server-only modules:Error Handling
Streaming
Stream responses withRawStream:
Best Practices
Use Composition API
Prefer<script setup> for cleaner code:
Suspense for Loading States
Use Suspense for async components:Combine with Vue Query
Use Vue Query for advanced data fetching:Single File Components
Leverage Vue’s SFC format:API Reference
Vue-Specific Exports
All exports from@tanstack/vue-start:
Differences from React
- Refs instead of State: Use
refinstead ofuseState - Composition API: Use composables instead of hooks
- Template Syntax: Use Vue’s template syntax with directives
- Reactivity System: Vue’s reactivity is based on Proxies
Related
- Vue Documentation
- TanStack Router
- TanStack Query
- React Start - React version for comparison