Open MercatoDocsSearch docsAPI reference

Installation

Standalone App

Scaffold the application in its own repository. Your module code lives there, while the package manager installs the Open Mercato framework and its dependencies.

If you need to modify the core itself, use the Monorepo guide instead.

Tip · Working with an AI coding agent?

Let create-mercato-app set up the agent harness (the wizard asks, or pass --agents claude-code, codex, cursor or all), then ask your agent to use the om-help skill. It maps what you want to build to the right guides and skills in your app.

macOS

Prerequisites

1. Git

xcode-select --install
# or via Homebrew after installing it (see below)

2. Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

3. Node.js 24

# Via Homebrew
brew install node@24
echo 'export PATH="/opt/homebrew/opt/node@24/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

# Or via nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
# Reopen terminal, then:
nvm install 24 && nvm use 24 && nvm alias default 24

Verify: node --version → v24.x.x

4. Yarn 4.17.1

corepack enable
corepack prepare [email protected] --activate

Verify: yarn --version → 4.17.1

The standalone app template includes a docker-compose.yml that starts PostgreSQL, Redis, and Meilisearch. Install Docker Desktop for Mac to use it.

Alternative – native PostgreSQL via Homebrew:

brew install postgresql@16
brew services start postgresql@16
createdb open-mercato

Then set DATABASE_URL manually (see below).


Create and configure the app

npx create-mercato-app my-app
cd my-app

This scaffolds a new standalone app with a .env.example and a docker-compose.yml for PostgreSQL, Redis and Meilisearch.


Bootstrap and start

With Docker Desktop (or another Docker engine) running:

yarn setup

yarn setup does the whole first run:

  1. Copies .env.example to .env when .env does not exist yet. An existing .env is never overwritten.

  2. Decides, within seconds and before installing anything, where PostgreSQL, Redis and Meilisearch come from:

    • the services in .env already answer and accept its credentials: it uses them;
    • nothing answers and Docker runs: it starts this app's containers on 5432, 6379 and 7700 and waits until their healthchecks pass (containers that already run are reused and their data is kept);
    • the ports are taken by something else (another project's containers, or a database with other credentials) and Docker runs: it starts an isolated stack on free ports and writes them to .env, so the other data is never touched;
    • no usable Docker and nothing usable answers: it stops with exit code 2, says what to fix and links running the services without Docker.

    It never installs Docker or asks for sudo. --infra, --random-ports, --ephemeral and --no-infra force one of these choices.

  3. Verifies the PostgreSQL, Redis and Meilisearch connections it will use.

  4. Installs dependencies, generates registries, runs migrations and yarn initialize. The first run seeds data and prints the admin credentials; later runs keep the existing database.

  5. Starts the dev server.

Open http://localhost:3000/backend and sign in with the credentials printed during setup. Next time, start the app with yarn dev (run yarn infra:up first if the containers are stopped).

Before using the app for anything other than local development, replace JWT_SECRET in .env with a strong value, for example from openssl rand -hex 32.

Port already in use

Without a flag, yarn setup moves to free ports on its own when Docker runs. With --infra it keeps the configured ports: if a native PostgreSQL (for example from Homebrew) already listens on 5432, it stops with exit code 2, names the port and suggests the next free one. Either stop that service, or pick another port in .env and keep DATABASE_URL in step:

POSTGRES_PORT=5433
DATABASE_URL=postgres://postgres:<url-encoded-password>@localhost:5433/open-mercato

REDIS_PORT and MEILISEARCH_PORT work the same way.

Using your own services instead of Docker

Already running PostgreSQL, Redis and Meilisearch (for example the Homebrew setup above)? Point .env at them and skip the containers:

cp .env.example .env
# set DATABASE_URL, REDIS_URL and the Meilisearch settings to your services
yarn setup --no-infra

--no-infra makes no Docker calls and keeps your URLs. It works with every setup variant (setup:classic, setup:reinstall, setup:reinstall:classic).

Infrastructure commands

yarn infra:up                    # start the containers and wait until they are healthy
yarn infra:down                  # stop them; data volumes are kept
yarn infra:down --volumes --yes  # stop them and DELETE the local database and search data
yarn setup --reinstall           # wipe the database and seed it again

On Linux containers and sandbox environments where the process cannot raise host inotify limits, yarn dev automatically warns and uses Next.js Webpack so the app can still start. To force a choice, set OM_DEV_BUNDLER=webpack or OM_DEV_BUNDLER=turbopack before running yarn dev.

Run multiple persistent standalone apps against the same PostgreSQL server

yarn setup, yarn dev, and friends accept an optional --database-name[=<name>] flag that rewrites the database segment of DATABASE_URL in ./.env. The flag is fully additive – without it, every script keeps its current behavior.

# explicit name; the script asks once whether to update .env (default yes)
yarn setup --database-name=client_a

# bare flag derives the database name from this app's folder
yarn setup --database-name

# one-off review run that does not edit .env
yarn dev --database-name=review_1720 --no-update-env

This makes it easy to run e.g. client-a/ and client-b/ side by side against the same PostgreSQL server without manually editing .env first. CI / non-interactive runs default to updating .env; pass --no-update-env (or set OM_DEV_DATABASE_UPDATE_ENV=false) to opt out.


Add your own modules

Drop modules into src/modules/ and register them in src/modules.ts with from: '@app'. See the customisation guide for details.

Eject a core module for deep customisation

When you need to modify the internals of a core module, eject it:

yarn mercato eject --list       # see which modules support ejection
yarn mercato eject currencies   # copy a module into src/modules/
yarn mercato generate all
yarn dev

Linux

Prerequisites

1. Git

# Debian / Ubuntu
sudo apt update && sudo apt install -y git

# Fedora / RHEL
sudo dnf install -y git

2. Node.js 24 via nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
# Close and reopen terminal, then:
nvm install 24 && nvm use 24 && nvm alias default 24

Verify: node --version → v24.x.x

3. Yarn 4.17.1

corepack enable
corepack prepare [email protected] --activate

Verify: yarn --version → 4.17.1

Docker Desktop for Linux: download here.

Or install the Docker Engine:

# Debian / Ubuntu
sudo apt install -y docker.io docker-compose-v2
sudo usermod -aG docker $USER
newgrp docker

Alternative – native PostgreSQL:

# Debian / Ubuntu
sudo apt install -y postgresql postgresql-contrib
sudo -u postgres createdb open-mercato

Then set DATABASE_URL manually (see below).


Create the app and start it

npx create-mercato-app my-app
cd my-app
yarn setup

With Docker running, yarn setup copies .env.example to .env if needed, checks Docker, starts PostgreSQL, Redis and Meilisearch, waits until they are healthy, then installs, migrates, initializes and starts the dev server. If your user cannot reach the Docker engine, it stops and tells you to add yourself to the docker group; it never asks for sudo itself. The macOS tab explains port conflicts and the infrastructure commands in detail; they work the same on Linux.

Using the native PostgreSQL above (and your own Redis and Meilisearch) instead of Docker:

cp .env.example .env
# set DATABASE_URL (for example postgres://postgres:<password>@localhost:5432/open-mercato), REDIS_URL and the Meilisearch settings
yarn setup --no-infra

--no-infra makes no Docker calls and keeps your URLs.

Open http://localhost:3000/backend and sign in with the credentials printed during setup. Next time, run yarn dev (with yarn infra:up first if the containers are stopped).


Add your own modules

Drop modules into src/modules/ and register them in src/modules.ts. See the customisation guide.

Eject a core module for deep customisation

yarn mercato eject --list
yarn mercato eject currencies
yarn mercato generate all
yarn dev

Windows

Tip · WSL2 recommended for development on Windows

For the best developer experience on Windows, use WSL2 with Ubuntu – it gives you native Linux tooling, faster file I/O, and full Docker support. See the dedicated Windows with WSL2 guide.

The steps below use native Windows tooling (PowerShell / cmd) and remain a valid alternative.

Prerequisites

1. Git

Download from git-scm.com/download/win. Choose "Git from the command line and also from 3rd-party software" when asked about PATH.

Configure line endings:

git config --global core.autocrlf input

2. Node.js 24

Download the Windows Installer (.msi) from nodejs.org/en/download. After installation, open a new PowerShell or Command Prompt window so the updated PATH takes effect.

Verify: node --version → v24.x.x

3. Yarn 4.17.1

corepack enable
corepack prepare [email protected] --activate

Warning · PowerShell execution policy error

If you see:

yarn.ps1 cannot be loaded because running scripts is disabled on this system.

Fix it with a one-time user-scoped change:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Then retry corepack prepare [email protected] --activate.

Alternative: use Git Bash or Command Prompt (cmd.exe) – the execution policy restriction does not apply there.

Verify: yarn --version → 4.17.1

4. Infrastructure services

The official Windows installer from postgresql.org/download/windows bundles pgAdmin 4, a full-featured database GUI.

  1. Run the EDB installer. Note the port (default 5432) and the postgres superuser password you set.

  2. Create the database in pgAdmin's Query Tool or PowerShell:

    psql -U postgres -c "CREATE DATABASE \"open-mercato\";"
    
  3. Set DATABASE_URL in .env (after scaffolding):

    DATABASE_URL=postgres://postgres:<your-password>@localhost:5432/open-mercato
    

For Redis (optional but recommended), run only the Redis service via Docker:

docker compose up -d redis

Option B – Docker Desktop (all infrastructure)

Install Docker Desktop for Windows with the WSL 2 backend enabled (Settings → General → "Use the WSL 2 based engine").

yarn setup starts and health-checks all services for you after scaffolding (see below).


Create the app and start it

npx create-mercato-app my-app
cd my-app

With Docker Desktop (Option B):

yarn setup

It copies .env.example to .env if needed, checks that Docker Desktop is running, starts PostgreSQL, Redis and Meilisearch, waits until they are healthy, then installs, migrates, initializes and starts the dev server. If a port is taken (for example by a native PostgreSQL on 5432, or by a port range Windows reserved for Hyper-V), it stops and names the port; set POSTGRES_PORT (and the port in DATABASE_URL), REDIS_PORT or MEILISEARCH_PORT in .env and run it again.

With native PostgreSQL (Option A):

Copy-Item .env.example .env
# set DATABASE_URL=postgres://postgres:<password>@localhost:5432/open-mercato, REDIS_URL and the Meilisearch settings
yarn setup --no-infra

--no-infra makes no Docker calls and keeps your URLs.

Open http://localhost:3000/backend and sign in with the credentials printed during setup. Next time, run yarn dev (with yarn infra:up first if the containers are stopped).


Add your own modules

Drop modules into src/modules/ and register them in src/modules.ts. See the customisation guide.

Eject a core module for deep customisation

yarn mercato eject --list
yarn mercato eject currencies
yarn mercato generate all
yarn dev

Publish a custom module

From your installed app, create a module and publish it independently of the app's repository:

npx create-mercato-module init visits
npx create-mercato-module publish visits

If the module already exists, skip init. See Publishing Custom Modules for authentication, dry runs, dedicated-repository development with link, and installation in another app from npm or GitHub.

Release channels

# Latest stable (default)
npx create-mercato-app my-app

# Latest snapshot from the main branch (published under the `develop` dist-tag)
npx create-mercato-app@develop my-app

For a specific version: npx [email protected] my-app

Full guide: customization/standalone-app

Previous: Set up Open Mercato locally · Next: VPS / Production Deployment