Getting Started
Getting started with Bazaar is quick and easy. To being, you create a Bazaar account, then create a Bazaar App 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 an Account
Section titled “Create an Account”To begin, create a free Bazaar account.
Register an App
Section titled “Register an App”On your Bazaar dashboard go to the Developers section by opening the menu and clicking Developers.
Next, click Create App.
- Give your app a name.
- Add your app’s URL.
- Optionally, add one or more redirect URIs (defaults to your app URL).
Click Create to get an app ID.
Install the library
Section titled “Install the library”Install the Bazaar library from NPM:
npm i @bzr/bazaarOr, load it from a CDN:
<script src="https://unpkg.com/@bzr/bazaar"></script>Initialize a Client
Section titled “Initialize a Client”import { BazaarApp } from "@bzr/bazaar";
const bzr = new BazaarApp({ appId: "example-app-id", loginRedirectUri: "http://example.com",});Create or Log in a User
Section titled “Create or Log in a User”// Add as a button click handlerbzr.login();Check if user is logged in:
bzr.isLoggedIn();Handle a successful log in:
bzr.onLogin(() => { // Handle user log in});Create a Collection
Section titled “Create a Collection”const tasksCollection = bzr.collection("tasks");Insert a Doc
Section titled “Insert a Doc”const task = { name: "Make dream apps with Bazaar" };tasksCollection.insertOne({ task });Fetch all Docs
Section titled “Fetch all Docs”const allTasks = await tasksCollection.getAll();Learn about the full capabilities of collections.