B2H BaaS

Quick Start

Get your first project up and running in 5 minutes.

1. Create a Project

Log in to the Console and create a new project.

  1. Click + Create Project
  2. Enter a project name
  3. Copy your Project ID from the settings page

2. Generate an API Key

In your project settings, generate an API key:

  1. Go to Settings → API Keys
  2. Click Generate New Key
  3. Copy the full key (you won't see it again)

3. Install the SDK

npm install @baas/js-sdk axios

4. Initialize the Client

import BaasClient from '@baas/js-sdk';

const client = new BaasClient({
  apiBase: 'http://localhost:3001',
  projectId: 'YOUR_PROJECT_ID'
});

5. Create Your First Document

async function main() {
  // Create a document
  const ref = await client.collection('tasks').add({
    title: 'My first task',
    completed: false,
    createdAt: new Date().toISOString()
  });
  
  console.log('Created document:', ref.id);
  
  // Query all tasks
  const tasks = await client.collection('tasks').list();
  console.log('All tasks:', tasks);
}

main();

6. Add Real-time Subscriptions

// Subscribe to changes
const unsubscribe = client.collection('tasks').onSnapshot((data) => {
  console.log('Tasks updated:', data);
});

// Later: stop listening
unsubscribe();

Next Steps