Skip to content

Getting Started

Getting started with Bazaar is quick and easy. To being, you create a Bazaar account, then create a Bazaar Project and register your app. Next, you install the JavaScript SDK, configure an instance of the SDK, then create and log in a user before interacting with data.

Create a Bazaar Account

To begin, create a Bazaar account.

Create a Bazaar Project

On your Bazaar dashboard go to the Developers section by clicking Developers.

Next, click Create Project.

  • Give your app a name.
  • Add your app’s URL.
  • Add one or more redirect URIs.

Install the JavaScript SDK

Install the SDK from NPM:

Terminal window
npm i @bzr/bazaar

Or, load it from a CDN:

<script src="https://unpkg.com/@bzr/bazaar"></script>

Create an SDK Client

const bzr = new Bazaar({
appId: "example-app-id",
loginRedirectUri: "http://example.com",
});

Create or Log in a User

// Add as a button click handler
bzr.login();

Check if user is logged in:

bzr.isLoggedIn();

Handle a successful log in:

bzr.onLogin(() => {
// Handle user log in
});

Create a Collection

const tasksCollection = bzr.collection("tasks");

Insert a Doc

const task = { name: "Make dream apps with Bazaar" };
tasksCollection.insertOne({ task });

Fetch all Docs

tasksCollection.getAll(); // returns a Promise

Learn about the full capabilities of realtime databases.