Skip to content
المشاريع

حول

Vite+ (vp) TanStack Start monorepo with shadcn/ui, Paraglide.js (i18n), Hono, oRPC, drizzle-orm, better-auth, Feature-Sliced Design (FSD), and more. Dockerized and opinionated.

البيانات والتحليلات

كيف تُقاس هذه الأرقام

النمو المقاس للنجوم

خلال 24 ساعة
٠
خلال 7 أيام
+١
خلال 15 يومًا
+٢
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

tsu!stack Logo
tsu!stack

License badge Last commit badge GitHub stars badge GitHub forks badge GitHub issues badge GitHub pull requests badge

Vite Plus (Vite+) TanStack Start monorepo with shadcn/ui, Paraglide.js (i18n), Hono, oRPC, drizzle-orm, and Better Auth. 🐋 Dockerized and opinionated. Compatible with the ⛅ Cloudflare Workers workerd runtime.

tsu!stack Screenshot

✨ Live Demo Deployments ✨
Dockerfile (Coolify)
Docker Compose (Coolify)
Merged Web + Server with Dockerfile (Coolify) | see branch
Merged Web + Server (Cloudflare Workers) | see branch

Table of contents

Getting started

Prerequisites

  • Use the Node.js version pinned in .node-version. Vite+ uses the same pin in Docker, and CI reads the same file.
  • Install Vite+ with curl -fsSL https://vite.plus | bash on macOS or Linux. On Windows, run irm https://vite.plus/ps1 | iex.
  • Install pnpm 12 or newer with vp install -g pnpm.
  • Use Docker for guided PostgreSQL setup and Compose deployments. Local D1 setup uses Wrangler.

Setup

Create your project with the project generator.

npm create tsu-stack@latest my-app

After guided local setup, start the app from your project directory.

cd my-app
vp run dev

If you skip guided local setup, use the commands the CLI prints to prepare your environment and database.

Before publishing a generated app, set its public identity, review its legal copy, and configure the crawler preferences you want to publish. See Project identity and Public discovery.

Keeping template changes

Generated projects include the sync-template skill. Use $sync-template with your coding agent to compare or apply updates from the matching tsu-stack branch. Review the numbered upstream changes and approve all or select a subset. Check .tsu-stack.jsonc for the commit used to create the project.

Running PostgreSQL variants with Docker locally

To run the apps and PostgreSQL in Docker, copy the environment example and set the values for your deployment. Compose builds the database URL from POSTGRES_USER, POSTGRES_PASSWORD, and POSTGRES_DB. Use vp run docker:up:build when you need to rebuild the images.

cp .env.docker.example .env.docker # And set environment variables as needed
vp run docker:up
vp run docker:up:build # OR: force a rebuild when you make changes to the code

Database migrations

Variant Database Migration command
separate, merged, cloudflare PostgreSQL vp run db:migrate
cloudflare-d1 Local D1 vp run db:migrate:local
cloudflare-d1 Remote D1 vp run db:migrate:remote

Verify the target before applying migrations. For PostgreSQL, check the effective DATABASE_URL that packages/db/drizzle.config.ts reads. For D1, check the DB binding in apps/web/wrangler.jsonc.

Tech stack

Technology Role in the project Alternatives and related tools
pnpm Manages workspace packages and shares dependency versions through catalogs. npm, Yarn
Vite+ Runs development, builds, tests, formatting, linting, and Git hooks. Turborepo, Nx, Vitest, Prettier, ESLint, husky, lint-staged, lefthook, tsdown, tsc
TanStack Start React framework with support for single-page apps, server rendering, incremental static regeneration, and TanStack Query. Node.js variants use Nitro. Worker variants use the Cloudflare Vite plugin. Next.js, Remix, React Router
Paraglide.js Compiles translations for the web app. i18next, next-intl
Hono Routes API requests on Node.js and Cloudflare Workers using web-standard APIs. Express.js, Fastify, Elysia.js
oRPC Defines typed API procedures and generates OpenAPI specs. Scalar displays the API reference. tRPC
Drizzle ORM Defines the database schema and provides typed queries. Prisma, TypeORM
PostgreSQL Stores relational data in the PostgreSQL variants. MySQL, MariaDB
Better Auth Handles self-hosted authentication and OAuth providers. Auth.js
Docker Runs containers for local development and deployment. Podman
shadcn/ui Provides accessible React components that you can customize. Chakra UI, Material UI, Mantine UI

Deployment

Deploy the web app and API independently with the default separate variant. The merged variants run both in one Node.js app or Cloudflare Worker.

Prefer one public origin so the web app receives the auth cookie during server rendering. Set both public URLs with their base paths and preserve those paths in the proxy. For separate origins, configure Better Auth cookies, trusted origins, CORS, and OPTIONS forwarding. Test sign-in and OAuth in Safari. See WebKit's tracking prevention guide.

For apps under a subpath, serve /robots.txt at the domain root. To advertise one sitemap index for multiple apps, publish it at the root and reference it in __root.tsx. See Google's robots.txt guide.

If you add a nonce-based content security policy (CSP), verify hydration with the policy sent as a response header. See the TanStack issues on duplicate hydration scripts and nonce timing.

Coolify

For Dockerfile builds, set the public URLs at build time and runtime. The Compose file passes database and auth credentials at runtime.

[!CAUTION] For Dockerfile builds, set the build-time scope for DATABASE_URL and BETTER_AUTH_SECRET to Not available during build. Keep both values available at runtime. See Coolify environment variable scopes.

If either app uses a base path, leave Strip Prefixes unchecked in Advanced. This applies to both deployment options.

Option 1: separate Dockerfiles

Separate Dockerfiles support rolling updates in Coolify with little downtime. Scaling the apps takes more work than with Docker Compose.

Server deployment
  1. Set Base Directory to /.
  2. Set Dockerfile Location to /apps/server/Dockerfile.
  3. Set Domain to a URL such as https://example.com/server.
  4. Expose port 5000.
Web deployment
  1. Set Base Directory to /.
  2. Set Dockerfile Location to /apps/web/Dockerfile.
  3. Set Domain to a URL such as https://example.com/web.
  4. Expose port 3000.

For each app, set the required values on the Environment Variables tab, then select Deploy. See Environment variables.

Option 2: Docker Compose

  1. Create an app in Coolify. Select Private Repository (with GitHub App) and choose your repository.
  2. Set Build Pack to Docker Compose and Docker Compose Location to /docker-compose.coolify.yaml.
  3. Include the port in each domain URL. For example, use https://example.com:3000/web for the web app and https://example.com:5000/server for the API. See Server deployment and Web deployment.
  4. Set the required values on the Environment Variables tab. See Environment variables.
  5. Select Deploy.

Cloudflare Workers

Choose cloudflare or cloudflare-d1 when you create the project. For example, run npm create tsu-stack@latest my-app -- --variant cloudflare. Both variants use the Cloudflare Vite plugin and run the Hono API in the Worker.

  • The cloudflare variant uses PostgreSQL. Set the runtime DATABASE_URL and apply PostgreSQL migrations before deployment. The Worker calls createDb() in the request path. See the PostgreSQL Worker branch.
  • The cloudflare-d1 variant uses a D1 database with a DB binding. Create the database with --setup cloudflare when you generate the project, or configure the binding in apps/web/wrangler.jsonc before deployment. See the D1 Worker branch.

Use the same public origin for the web app and API. If the web app is at https://example.com/web, set VITE_WEB_URL to that URL and VITE_SERVER_URL to https://example.com/web/server. Pass the same URLs to build and deploy. Provide BETTER_AUTH_SECRET to the deploy job through its secret store.

Varlock uploads schema-managed values as Worker variables and secrets. Before your first Varlock deploy, add any existing dashboard variables and secrets your app uses to the schema and supply their values to the deploy job. Varlock replaces the previous set. See Varlock's Cloudflare guide.

[!WARNING] For cloudflare-d1, vp run deploy applies remote D1 migrations before publishing the Worker. Verify the Cloudflare account, Worker, and DB binding before deploying manually or enabling automated deployments.

For a manual deployment, run vp exec wrangler login from apps/web. Build and deploy from the project root.

vp run build
vp run deploy

Git-based CI/CD

Connect your repository to Workers Builds and select the branch with the Worker variant. Set the build command to pnpm exec vp run build and the deploy command to pnpm exec vp run deploy. Provide the deployment values in the Workers Builds environment. See the Workers Builds configuration guide.

Dokploy

Use the included Dockerfiles to deploy the web app and API on Dokploy.

  1. Connect your repository to two applications, one for the API and one for the web app.

  2. Select Dockerfile as the build type for both applications and use the settings below.

    Setting Server Web
    Dockerfile Path apps/server/Dockerfile apps/web/Dockerfile
    Docker Context Path . (repository root) . (repository root)
    Docker Build Stage production production
  3. Set VITE_SERVER_URL and VITE_WEB_URL as Build Time Arguments and runtime variables. If you use imgproxy, set its public variables on the web app.

  4. Set DATABASE_URL and BETTER_AUTH_SECRET under the runtime Environment Variables for both applications.

  5. Assign domains that match the URLs. Route to container port 5000 for the API and 3000 for the web app. Save the settings and deploy both applications.

Varlock supplies disposable credentials during Docker builds and validates production credentials at startup. Rebuild when the public URLs change. For build steps that need credentials, use a BuildKit secret mount.

Deploying to other platforms

The TanStack Start web app uses Nitro. To deploy to a platform such as Cloudflare Workers, Vercel, AWS Lambda, or Deno Deploy, set its Nitro preset in apps/web/vite.config.ts. See the Nitro deployment targets.

Run the standalone API in apps/server on Node.js, such as in a container, on a virtual server, or on a Node.js serverless platform. For Cloudflare Workers, use a Worker variant.

Environment variables

Continue to set VITE_WEB_URL, VITE_SERVER_URL, and optional VITE_IMGPROXY_URL under their existing names. Use HTTP or HTTPS base URLs with an optional mount path. Keep credentials, query strings, and fragments out of these URLs. VITE_IMGPROXY_SIGNATURE is public. Supply only a precomputed signature, _, or insecure.

The Varlock schema defines the project settings. Copy the local example to .env.local, run vp run auth:secret, and put the generated value in BETTER_AUTH_SECRET. Exported variables override local values.

If you already have packages/env/.env, copy its settings into .env.local. Preserve your database URL and Better Auth secret. For Workers, also move settings from apps/web/.dev.vars and move that file out of the app before starting Vite. Use vp exec varlock load --agent to check the result.

Server

Variable Required Default Description
VITE_SERVER_URL Yes - API base URL, including any subpath, such as https://example.com/server.
VITE_WEB_URL Yes - Web app base URL, including any subpath, such as https://example.com/web.
BETTER_AUTH_SECRET Yes - Shared production secret for the web app and API. Generate it with vp run auth:secret.
BETTER_AUTH_TRUSTED_PROXIES No - Exact IPs or narrow CIDRs of proxies that append X-Forwarded-For, separated by commas. Leave empty for direct connections.
DATABASE_URL Yes for PostgreSQL - PostgreSQL connection string.
ENABLE_OPEN_API_DOCS No false Publishes /openapi.json and /docs under the API base path. Use the same value when building the web app.

Web

Variable Required Default Description
VITE_SERVER_URL Yes - API base URL, including any subpath, such as https://example.com/server.
VITE_WEB_URL Yes - Web app base URL, including any subpath, such as https://example.com/web.
BETTER_AUTH_SECRET Yes - Use the same Better Auth secret as the API.
DATABASE_URL Yes for PostgreSQL - PostgreSQL connection string.
VITE_IMGPROXY_URL No - URL of your imgproxy container for image optimization.
VITE_IMGPROXY_SIGNATURE No _ imgproxy signature path segment. If your setup requires it, use insecure or a precomputed signature.

Contributing

For web changes, check where the code belongs and when to move it into a shared layer. See the project organization guide.

Check whether to open an issue before you start work. See the contributing guide.

Fork the repository, commit your changes, and push them to your fork. Then open a pull request. For help with your first pull request, see this GitHub pull request tutorial.

Report bugs in GitHub issues. You can also star or share the repository.

Acknowledgements

This repository builds on mugnavo/cove-monorepo.

License

The project uses the MIT License.

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…