module: getting-startedKroxt BaaS SDK v1.0.5

Getting Started Module

Kroxt BaaS is a unified backend platform providing developers with secure user authentication, MongoDB collection CRUD mapping, multipart storage buckets, transactional mail triggers, and VM serverless functions.

1. Install the SDK

Install the official Kroxt client SDK package in your frontend project using npm:

npm install @kroxt/baas-sdk

2. Initialize for Web & Next.js

Configure the client by passing your workspace projectId and credentials found on the project overview page:

import { Kroxt } from "@kroxt/baas-sdk";

export const baas = new Kroxt({
  projectId: "YOUR_PROJECT_ID",
  apiKey: "YOUR_PUBLIC_API_KEY",
});

3. Initialize for React Native (Expo)

React Native handles tokens asynchronously. Simply install @react-native-async-storage/async-storage and pass the adapter module to your initialization block:

import { Kroxt } from "@kroxt/baas-sdk";
import AsyncStorage from "@react-native-async-storage/async-storage";

export const baas = new Kroxt({
  projectId: "YOUR_PROJECT_ID",
  apiKey: "YOUR_PUBLIC_API_KEY",
  storage: AsyncStorage, // Direct support for async storage!
});

4. TypeScript Type Safety

Import the Document type adapter to wrap your custom interface schemas, automatically equipping documents with standard metadata fields (_id, createdAt, updatedAt, projectId, collectionId):

import type { Document } from "@kroxt/baas-sdk";

export interface MessageData {
  text: string;
  sender: string;
  senderEmail: string;
  roomId: string;
  createdAt: string;
  reactions?: Reaction[];
}

export type Message = Document<MessageData>;