mirror of
https://github.com/trailbaseio/trailbase
synced 2026-04-21 21:47:55 +00:00
| .. | ||
| guests | ||
| public | ||
| screenshots | ||
| src | ||
| traildepot | ||
| .gitignore | ||
| eslint.config.mjs | ||
| index.html | ||
| Makefile | ||
| package.json | ||
| README.md | ||
| server.js | ||
| tsconfig.json | ||
| vite.config.ts | ||
Collaborative Clicker App with SSR
This app serves as a showcase for "realtime" API subscriptions and server-side rendering (SSR). This app uses Solid but the same approach applies to React, Vue, Svelte, Preact, ... .
Generate the App
pnpm create vite@latest <project-dir>
Follow CLI template assistant: Others > create-vite-extra > ssr-[vue|react|preact|svelte|solid].
The resulting template is set up to use "express.js", see '/server.js'. In order to serve with TrailBase instead we have to:
- Tell vite to inline deps when building the server entry point:
cat <project-dir>/vite.config.ts export default defineConfig({ plugins: [<react|vue|solid|svelte|...>], ssr: { noExternal: true, // IMPORTANT }, }) - Set up
traildepot/scripts/main.tsto:- pick up the generated HTML template for the client,
- generate the hydration script in the HTML head,
- and run the server's entry-point to render the initial HTML body.