Skip to content

Local Development

To test your Bazaar app locally, run the mock:

Terminal window
npx @bzr/bazaar-mock

This will launch a mock Bazaar server on port 3377. It will also create an app with ID “test” that is expected to run on http://localhost:8080.

You can change these defaults with the following options.

npx @bzr/bazaar-mock [options]
-i specify app ID. It is optional and defaults to 'test'.
-u specify app URL. It is optional and defaults to 'http://localhost:8080'.
-r specify redirect URI. Can be specified multiple times. It is optional and defaults to app URL.
-n specify app name. Default is 'Test App'.
-o specify the app owner's email. Log in with it to manage the app. Default is 'owner@example.com'.
-p specify port. Default is 3377.
-c config file: users and their limits, products, purchases.
-h show this help
Example: npx @bzr/bazaar-mock -i my_app -u http://localhost:8080 -r http://localhost:8080 -r http://localhost:8081

The mock server is close in functionality with the real server. You can log in on http://localhost:3377 with any email, no code required. New accounts choose a handle and name first. This gives you access to your mock Bazaar dashboard, where you can also add more apps. Log in as the app owner (owner@example.com by default) to manage the test app. Data is kept in memory and only exists as long as the mock server is running. Uploaded files are written to .db/blobs/ in the directory you start the mock from.

Payments work without money: anyone can create products, and the purchase popup buys at once (Buy, Switch, Cancel). Nobody has limits, unless a config file gives them (-c bazaar.mock.json): users made at start with a storage limit, a monthly API call limit or no email, orgs with their admins, members and storage limit, plus products and purchases. The format is in the mock’s README.

When your bundler runs in development mode (NODE_ENV=development, e.g. Vite’s dev server), the Bazaar library connects to the mock server by defaulting bazaarUri to http://localhost:3377. In production, bazaarUri is set to https://cloud.bzr.dev. The CDN build (unpkg.com/@bzr/bazaar) always defaults to https://cloud.bzr.dev. You can optionally set this URL when creating a BazaarApp.

import { BazaarApp } from "@bzr/bazaar";
const bzr = new BazaarApp({
appId: "test",
loginRedirectUri: window.location.origin + window.location.pathname,
bazaarUri: "http://localhost:3377",
});