A minimal template for building server-side rendered React applications with τjs (taujs).
- Server-Side Rendering (SSR) with React 19
- Automatic Hydration with @taujs/react
- Fast Development with Vite HMR
- Type-Safe with TypeScript
- Easy Configuration with taujs.config.ts
- Fastify for the runtime server
npm installnpm run devVisit http://localhost:5173 to see your app running.
npm run buildnpm starthttps://taujs.dev/reference/taujs-config/
The main configuration file for τjs. Here you define:
- Server settings (host, port)
- Apps (entry points for your applications)
- Routes (URL patterns with rendering strategies)
export default defineConfig({
server: {
host: "localhost",
port: 5173,
},
apps: [
{
appId: "main",
entryPoint: "client",
plugins: [pluginReact()],
routes: [
{
path: "/",
attr: {
render: "ssr",
data: async () => ({
message: "Hello from τjs!",
}),
},
},
],
},
],
});Add new routes in taujs.config.ts:
routes: [
{
path: "/",
attr: {
render: "ssr",
data: async () => ({ message: "Home" }),
},
},
{
path: "/about",
attr: {
render: "ssr",
data: async () => ({ message: "About Us" }),
},
},
];Use the useSSRStore hook to access server-rendered data:
import { useSSRStore } from "@taujs/react";
export function MyComponent() {
const data = useSSRStore<{ message: string }>();
return <h1>{data.message}</h1>;
}τjs supports two server rendering modes:
Complete HTML rendered on server, then hydrated on client.
attr: {
render: "ssr",
data: async () => ({ /* data */ }),
}Progressive HTML streaming with React 18+ suspense.
attr: {
render: "streaming",
meta: { title: "Page Title" }, // required for streaming
data: async () => ({ /* data */ }),
}npm run dev- Start development server with hot reloadnpm run build- Build for productionnpm run build:client- Build client assets onlynpm run build:server- Build server bundle onlynpm start- Run production server
- Add more routes in
taujs.config.ts - Create services for data fetching (see docs)
- Add authentication middleware
- Configure CSP (Content Security Policy)
- Set up microfrontends for multi-app architecture
This starter does not include a package-lock.json.
That’s intentional - leaving it out ensures that new projects always install the latest τjs versions on first install.
When you create a project from this template:
- Run
npm install - A fresh
package-lock.jsonwill be created for your project - Commit it as normal in your own repo
The .gitignore in the starter excludes package-lock.json so the template itself doesn’t freeze versions. Remove this entry if you want to commit your lockfile!
τjs packages are set as 'latest' and don’t auto-update once your project has a lockfile. To pull in the latest compatible versions:
npm update @taujs/react @taujs/serverIf you want to jump to the newest published versions regardless of semver:
npm install @taujs/react@latest @taujs/server@latestIf things get messy or you want a full re-resolve:
rm -rf node_modules package-lock.json
npm installMIT