trailbase/examples/collab-clicker-ssr
2026-03-27 17:10:50 +01:00
..
guests Update JS dependencies. Upgrade to TS6. 2026-03-26 11:21:16 +01:00
public Add a custom Hero banner to langing page with install instructions and remove overly prominent roadmap (still in docs). 2025-07-17 13:54:11 +02:00
screenshots Add a "Collaborative Clicker + SSR" tutorial to the docs. 2025-01-25 11:16:08 +01:00
src Minor: fix typo in SSR example. 2025-12-16 22:05:29 +01:00
traildepot Move "main" DB migrations into <traildepot>/migrations/main to follow latest best practices. 2025-12-12 13:04:02 +01:00
.gitignore Clean up examples and tutorials as well as minor doc tweaks. 2025-01-24 14:26:16 +01:00
eslint.config.mjs Migrate examples/collab-clicker-ssr to WASM. 2025-09-09 18:22:36 +02:00
index.html Clean up examples and tutorials as well as minor doc tweaks. 2025-01-24 14:26:16 +01:00
Makefile Migrate examples/collab-clicker-ssr to WASM. 2025-09-09 18:22:36 +02:00
package.json TS client: rename s/Event/ChangeEvent + re-export as Event to stop confusing rollup. 2026-03-27 17:10:50 +01:00
README.md Add a "Collaborative Clicker + SSR" tutorial to the docs. 2025-01-25 11:16:08 +01:00
server.js Clean up examples and tutorials as well as minor doc tweaks. 2025-01-24 14:26:16 +01:00
tsconfig.json Cleanup: move all Rust code into a crates/ directory. 2025-08-07 10:02:32 +02:00
vite.config.ts Update admin UI to tailwind v4. 2025-09-12 12:56:06 +02:00

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:

  1. 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
      },
    })
    
  2. Set up traildepot/scripts/main.ts to:
    • 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.