Requirements
Create a project
- create-gato-app (recommended)
- gato create from a clone
create-gato-app picks the highest v<x.y.z> release tag of the kit, checks your Node version against it, downloads that tag as a tarball (no clone, no git history) and asks for modules, languages, display name, admin email, file storage (with uploads) and mail. It assembles the project with gato create, writes .env with generated secrets and a unique COMPOSE_PROJECT_NAME, and, unless you skip it, starts Docker, installs dependencies, runs the first migration, creates the admin and commits. Before starting Docker it moves any busy service port to the next free one and updates .env (Busy ports). The new project gets gato-cli as a devDependency, so inside it you run the CLI as npx gato <command>.Useful flags:create-gato-app.create-gato-app talks to the GitHub API to find the latest tag. Anonymous requests are limited to 60 per hour. If you hit the limit, set GITHUB_TOKEN (or GH_TOKEN, or log in with the gh CLI), wait for the limit to reset, or use --kit <path> with a local kit checkout.What create does
- Validates the project name: the last segment of the directory, 2-50 characters, lowercase letters, digits and hyphens, starting with a letter. The target directory must be empty or not exist.
- Copies the core and the chosen modules, replacing placeholders with your project name. The database becomes
<slug with underscores>(my-app→my_app). - Writes
.wa/kit.jsonand runsgato generateto build the module registry. - Writes
.envfrom.env.examplewith a randomBETTER_AUTH_SECRETand, if given,ADMIN_EMAIL. The file gets mode600. - Runs
git init,npm installand a first commit (chore: initial commit from GatoJS v<version>). - With
--setup:docker compose up -d --wait,npx prisma migrate dev --name init, andnpm run admin:create -- --email <email>when an admin email is known. - Prints the next steps that are still left to do.
Modules, Languages, Display name, Admin email (empty = skip) and whether to run the database setup now ([y/N]).Manual setup
Run these in the project root, in this order, if you created the project without--setup, or if setup stopped half way. The database must be running before the migration, and the migration must exist before you create the first account.
Install dependencies
create already ran npm install.postinstall runs prisma generate, which writes the Prisma client to src/generated/prisma (git-ignored). prepare installs the git hooks (husky).Check .env
create already wrote .env. If you are working in a fresh clone of the kit itself, create it:Check the ports
localhost:5432, and your connections then reach the local server, not the container. If a port is taken, change it first.Start PostgreSQL and mailpit
--wait returns once the services are healthy. Without it, repeat docker compose ps until db shows (healthy).Create the database schema
prisma/schema/. Commit the generated prisma/migrations/ folder. See Database and migrations.Create the first account
-- separator is required, otherwise npm swallows --email. The generated password is printed once. See First admin account.Start the app
http://localhost:3000/en/sign-in and sign in.Docker services
docker-compose.yml defines two services. Use their names in commands such as docker compose logs db.
volumes/postgres/ (git-ignored), so it survives docker compose down. The file ends with a wa:services region where modules add their own services; the uploads module adds MinIO there behind the s3 Compose profile. Do not edit that region by hand; see Module registry.
Environment file
.env is git-ignored. It is read by Next.js (dev, build, start), by Prisma, admin:create and Vitest through dotenv (.env.local first, then .env; shell variables win over both), and by Docker Compose for the port variables.
You do not need to change anything for local work. Typical edits:
.env, npm run dev prints a report of every problem and exits. Validation results are cached for the life of the process, so restart npm run dev after editing .env. npm run build does not validate the environment.
Runtime modes
Three flags change how the app behaves. Each takestrue or false; missing or empty means false. Any other value (1, yes) fails validation. Restart the server after changing a flag.
MULTI_ORG and AUTH_PUBLIC_SIGNUP:
- Global
adminandsuperadminaccounts have an Invite user button on the Users page. It creates an account in the active organization and emails a link to set a password. - The sign-in page never links to sign-up. Users reach
/sign-upby typing it or from an invitation page. - Signing up with an
invitationIdalways works and joins the organization from the invitation, with its role. - An organization switcher appears whenever an account can access more than one organization.
First admin account
npm run admin:create creates an account and, on an empty database, the first organization. It needs a running database with the migration applied and a valid .env.
ADMIN_PASSWORD; if that is empty or missing, it generates a 20-character password and prints it once.admin or superadmin. superadmin is the support account for the team that builds and maintains the app. See Superadmin and service mode.- New account: gets the chosen global role and a verified email, so the first sign-in needs no email.
- Organization: on an empty database it creates an organization and makes the account its
owner. If an organization already exists, it adds the account to the oldest one asownerinstead of creating a second. - Re-running is safe: it creates nothing new and never changes the password.
- Existing account with a lower role: the script asks before upgrading (
User <email> already exists. Grant role <role>? [y/N]) and stops without consent. It never downgrades a role.
Change ports
Busy ports in create-gato-app
Sincecreate-gato-app 0.3.15, the installer checks the host ports docker-compose.yml publishes before it starts Docker: the database, mailpit and, with the s3 profile, MinIO. A busy port moves to the next free port, up to 100 above it. The installer writes the port variable (DB_PORT, MAILPIT_UI_PORT, MAILPIT_SMTP_PORT, MINIO_PORT, …) and every .env value that uses the old port on localhost or 127.0.0.1 (DATABASE_URL, SMTP_URL, S3_ENDPOINT) and prints each move:
127.0.0.1:5432, which Docker on macOS would otherwise run next to without an error.
Only port entries in the form ${VAR:-port}:port or port:port are checked; an entry with a host address, such as 127.0.0.1:5432:5432, is skipped. The installer does not move a port and stops before Docker with the variables to set when the port is written literally in docker-compose.yml, when its variable is set in your shell (Compose prefers it over .env), or when no port within 100 is free. Set the ports by hand as described below, then run the remaining steps it prints. For a variable set in your shell, unset it (or export the new port) first, otherwise Compose keeps using the busy port. For a literal mapping such as 5432:5432, change the host side in docker-compose.yml (or turn it into ${DB_PORT:-5432}:5432) and update the URL that uses it in .env.
Database and mailpit
Each Docker port lives in two places that nothing keeps in sync: Compose readsDB_PORT, while the app and Prisma read only DATABASE_URL. Change both together in .env:
docker compose up -d. Compose recreates the changed services and keeps the data in volumes/postgres/. If the port is held by another GatoJS project’s containers, you can also run docker compose stop in that project instead.
npm run test:integration and npm run test:e2e read DB_PORT, MAILPIT_UI_PORT, MAILPIT_SMTP_PORT and MINIO_PORT from the shell, .env.local or .env, in that order, so they reach the moved containers. A value in the shell or .env.local wins over .env, and INTEGRATION_DATABASE_URL and INTEGRATION_S3_ENDPOINT win over DB_PORT and MINIO_PORT, so update or remove those when you move a port; see Testing.
App port
Set the Next.js port with-p or a shell variable, not in .env (Next.js picks the port before it loads .env):
APP_URL (for example APP_URL=http://localhost:3001) and restart. better-auth trusts only the origin from APP_URL by default, and email links are built from it.
Without -p, when 3000 is busy, next dev silently moves to the next free port. Sign-in then fails with Invalid origin in the terminal until you update APP_URL.
Open the app at the configured origin
Open the app at exactly the address inAPP_URL. http://127.0.0.1:3000 and http://localhost:3000 are two different origins. With APP_URL=http://localhost:3000, signing in from 127.0.0.1 gets a 403 with the code INVALID_ORIGIN from better-auth, the form shows only a generic sign-in error, and every protected page keeps redirecting to /sign-in. It looks like a redirect loop, but it is the origin check. Session cookies also belong to a single host name.
Troubleshooting
Install prints EBADENGINE or rewrites package-lock.json
Install prints EBADENGINE or rewrites package-lock.json
npm install with npm 10 instead of the pinned npm 11 (lock file changes).Fix: install the latest Node 22 (nvm install). Revert the lock file with git checkout package-lock.json and use npm ci, or npx -y [email protected] install when you need to add packages.Cannot find module @/generated/prisma/client
Cannot find module @/generated/prisma/client
--ignore-scripts or deleting src/generated/.Fix: npm run db:generate.docker compose up reports a port in use
docker compose up reports a port in use
port is already allocated (another container) or address already in use (another program).Fix: change the port or stop the other project’s containers.Sign-in keeps returning to /sign-in
Sign-in keeps returning to /sign-in
APP_URL origin, for example 127.0.0.1 instead of localhost, or another port. better-auth rejects the sign-in with INVALID_ORIGIN.Fix: open the app at the exact APP_URL address, or change APP_URL and restart (Open the app at the configured origin).Prisma says datasource.url is required
Prisma says datasource.url is required
prisma.config.ts did not find DATABASE_URL, usually because there is no .env. The dotenv line shows injected env (0).Fix: create .env from .env.example in the project root.Prisma or admin:create cannot reach the database
Prisma or admin:create cannot reach the database
P1001: Can't reach database server, an authentication error, Drift detected, or commands that succeed but changes never reach your container.Cause: the container is not running yet, the port in DATABASE_URL differs from DB_PORT, or another PostgreSQL listens on the same port and receives the connection.Fix:- Compare the ports:
grep -E '^(DB_PORT|DATABASE_URL)=' .env. WithoutDB_PORTthe port must be 5432. Shell variables win over.env, so also checkecho "$DB_PORT $DATABASE_URL". - Stop your containers (
docker compose stop) and re-run the port check. If the database port is still taken, another program holds it: changeDB_PORTandDATABASE_URL. docker compose up -d --wait.- Run the migration and
admin:createagain, because they may have gone to a different database.
The server exits with 'Invalid environment variables'
The server exits with 'Invalid environment variables'
- <VARIABLE>: <message>. A ✓ Ready line before the report does not mean the server is running.NODE_ENV=production, which npm start sets. Running a production build locally therefore needs a RESEND_API_KEY (any non-empty value works while SMTP_URL is set) and your own secret.admin:create says 'Pass --email or set ADMIN_EMAIL' or 'Unexpected argument'
admin:create says 'Pass --email or set ADMIN_EMAIL' or 'Unexpected argument'
-- separator and npm passes the bare address to the script.Fix: npm run admin:create -- --email [email protected].The root URL returns 404
The root URL returns 404
/ redirects to /dashboard, and /dashboard without a session redirects to /sign-in. In an older project the app has no home page: go to /sign-in (or /en/sign-in). Any other unknown address shows the localized “Page not found” page (Home and not-found pages).Sign-in fails although the page loads
Sign-in fails although the page loads
npm run dev terminal. Invalid origin: <origin> means APP_URL has a different port than the server (App port). Otherwise the credentials are wrong or the database is unreachable. A forgotten password can be reset through mailpit.Emails do not show up in mailpit
Emails do not show up in mailpit
SMTP_URL points at another port than MAILPIT_SMTP_PORT, the mail service is down (the terminal shows [MAILER] Failed to send), or SMTP_URL is empty. With an empty SMTP_URL the app falls back to Resend if RESEND_API_KEY is set, and otherwise only logs SMTP_URL and RESEND_API_KEY not set, email not sent.Fix: set SMTP_URL=smtp://localhost:1025 (or your custom port) and check docker compose ps. See Email.An invitation link fails
An invitation link fails