TanStack Start
TanStack Start is a full-stack Web framework based on TanStack Router, now supporting React and Solid. Combining Vite build capacity, it provides type-safe routes, Server-side rendering (SSR), streaming, Server Functions, and other features, enabling you to build high-performance full-stack Web applications.
Note:
Currently, Makers supports TanStack Start version 1.0+ and enables full-stack deployment.
Core Features
Type-safe routing: Fully support TypeScript with type inference for routing parameters and data loading.
Full-stack framework: Support server-side rendering, API routing, and integration of front-end and back-end development.
File-based routing: Based on the file system route agreement, automatically generate a route tree.
Data loading: Built-in loader mechanism supports server-side data retrieval.
Streaming rendering: Supports React 18 Suspense and streaming SSR.
Getting Started
You can deploy TanStack Start projects on the EdgeOne Makers platform using the following methods:
Import a TanStack Start project from a Git repository
Select the TanStack Start template from the Makers template library.
Use the
@edgeone/tanstack-start framework adapter to deploy a local projectTo understand the deployment performance of TanStack Start on Makers, click the example template below:
Makers Support for TanStack Start
TanStack Start Feature | System Support |
Server-Side Rendering (SSR) | ✓ |
Static Site Generation (SSG) | ✓ |
Single Page Application (SPA) | ✓ |
Route Loaders | ✓ |
Server Functions | ✓ |
File-based Routing | ✓ |
Streaming | ✓ |
Deploying a TanStack Start Project on Maker
@edgeone/tanstack-start is a Vite plugin specifically designed for the Makers platform. It automatically builds TanStack Start applications into Makers deployment artifacts. When used with the Makers scaffolding, it enables rapid deployment of TanStack Start projects.To deploy a TanStack Start project on Makers, refer to the following operational steps.
1. Installing an Adapter
npm install @edgeone/tanstack-start
2. Configure Vite
In
vite.config.ts, introduce and use @edgeone/tanstack-start:import { defineConfig } from "vite";import { tanstackStart } from "@tanstack/react-start/plugin/vite";import viteReact from "@vitejs/plugin-react";import edgeoneAdapter from "@edgeone/tanstack-start";export default defineConfig({plugins: [tanstackStart(),viteReact(),edgeoneAdapter(), // Add the Edgeone adapter],});
3. Deploy Project
Git Connection Deployment
After seamless integration of the adapter, commit the project to GitHub or GitLab, and use Git connection deployment.
CLI Deployment
Install the Makers scaffolding tool (see EdgeOne CLI). After configuration, use the command to deploy:
edgeone makers deploy
Note:
The current adapter does not support concurrent use with Nitro plugins. If you need to use Nitro, wait for the official EdgeOne Makers preset to be released.
Server-Side Rendering (SSR)
TanStack Start enables SSR by default. Use the
loader function to retrieve data from the server.// app/routes/posts.$postId.tsximport { createFileRoute } from "@tanstack/react-router";export const Route = createFileRoute("/posts/$postId")({loader: async ({ params }) => {const post = await fetchPost(params.postId);return { post };},component: PostComponent,});function PostComponent() {const { post } = Route.useLoaderData();return (<article><h1>{post.title}</h1><div>{post.content}</div></article>);}
Static Site Generation (SSG)
Support pre-rendering static pages during build.
// app/routes/about.tsximport { createFileRoute } from "@tanstack/react-router";export const Route = createFileRoute("/about")({// Static data pre-rendered at build timeloader: () => ({title: "About Us",description: "Learn more about our company.",}),component: AboutComponent,});function AboutComponent() {const data = Route.useLoaderData();return (<div><h1>{data.title}</h1><p>{data.description}</p></div>);}
Server Functions
TanStack Start supports server functions, which can run on the server for sensitive operations.
// app/routes/api.tsimport { createServerFn } from "@tanstack/react-start/server";export const getServerTime = createServerFn().handler(async () => {return new Date().toISOString();});export const createUser = createServerFn().validator((data: { name: string; email: string }) => data).handler(async ({ data }) => {// Execute a database operation on the serverconst user = await db.users.create(data);return user;});
Streaming Rendering
Support streaming rendering through React 18's Suspense, gradually transmitting page content.
import { Suspense } from "react";import { createFileRoute, Await } from "@tanstack/react-router";export const Route = createFileRoute("/dashboard")({// Return Promises without awaitingloader: () => ({posts: fetchPosts(),stats: fetchStats(),}),component: DashboardComponent,});function DashboardComponent() {const { posts, stats } = Route.useLoaderData();return (<div><Suspense fallback={<p> Loading posts... </p>}><Await promise={posts}>{(data) => <PostList posts={data} />}</Await></Suspense><Suspense fallback={<p> Loading stats... </p>}><Await promise={stats}>{(data) => <StatsPanel stats={data} />}</Await></Suspense></div>);}
