Local Development
To test your Bazaar app locally, run the mock:
npx @bzr/bazaar-mockThis 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. -h show this helpExample: npx @bzr/bazaar-mock -i my_app -u http://localhost:8080 -r http://localhost:8080 -r http://localhost:8081The 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.
Connect your app to the mock server
Section titled “Connect your app to the mock server”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",});