TypeScript SDK Introduction
The Lovrabet TypeScript SDK is a lightweight JavaScript/TypeScript SDK that provides convenient Lovrabet platform data access capabilities for both Web and Node.js environments.
Current Version: | npm: @lovrabet/sdk
Technical Features
Written in TypeScript and compiled to JavaScript, it runs in both browser and Node.js environments:
Web
Supports all major frontend frameworks:
- React - Create React App, Vite, Remix, etc.
- Vue - Vue 3, Vite, Vue CLI, etc.
- Angular - Angular 14+, etc.
- Others - Svelte, Solid.js, vanilla JavaScript, etc.
Node.js
Supports all major Node.js frameworks and runtimes:
- SSR Frameworks - Next.js, Nuxt.js, Astro, etc.
- Backend Frameworks - Express, Koa, Fastify, Nest.js, Hono, etc.
- Runtimes - Node.js 18+, Bun, Deno, etc.
Cross-Platform Support
- Mini Programs - WeChat Mini Program, Alipay Mini Program, uni-app, etc.
- Desktop Applications - Electron, Tauri, etc.
Core Features
- Easy to use - Get started in 5 minutes with a clean and intuitive API design
- Flexible configuration - Supports multiple configuration methods to meet different project needs
- Multiple authentication - Supports user Token, OpenAPI keys, Cookie and other authentication methods
- Complete CRUD - Provides full data operation features including create, read, update, and delete
- Native TypeScript support - Complete type definitions for type-safe development
- High performance - Built-in caching, request deduplication, batch processing and other optimizations
- Model Aliases v1.2.0+ - Supports friendly model alias access
Main Features
Data Operations
- List queries (supports pagination, filtering, sorting)
- Single record retrieval
- Create new records
- Update existing records
- Delete records
Advanced Queries
- Filter Advanced Query - Complex condition filtering, field selection, multi-field sorting
- Custom SQL Query v1.1.19+ - Execute registered custom SQL
- BFF Endpoint Calls v1.2.0+ - Call backend functions
Advanced Features
- Multi-project support
- Request caching and optimization
- Error handling and retry
- Performance monitoring
Documentation Navigation
Getting Started
- SDK Introduction — SDK overview, technical features, core capabilities
- Quick Start — 5-minute getting started guide
- Configuration Details — Multiple configuration methods and multi-project support
- Authentication Configuration — Three authentication methods configuration and security notes
Data Operations
- API Usage Guide — CRUD operations, query parameters, batch processing
- Filter API — Complex condition filtering, field selection, multi-field sorting
- Aggregate API — Group statistics, sum, average
- SQL API — Execute platform pre-registered custom SQL
- BFF API — Call backend functions
- User List Query — User list query examples
- Multi-Table Query — Multi-table join queries
Advanced Features
- Model Aliases — Friendly alias access methods
- Advanced Features — Multi-project management, performance optimization, error handling
- Error Handling — LovrabetError details and debugging tips
- Syntax Sugar — Convenient shorthand provided by SDK
- TypeScript Support — Type definitions and type-safe development
- SQL Tutorial — SQL basics tutorial
Reference
- API Reference — Complete API reference documentation
- MCP SDK Usage — MCP SDK integration guide
- Practical Examples — Complete integration examples for React, Vue, Node.js, etc.
- Troubleshooting — Common problem diagnosis and solutions
- Frontend Platform — Frontend platform related features
Quick Preview
Installation
npm install @lovrabet/sdk
Basic Usage
Using the Lovrabet CLI you can generate configuration with a single command, saving you the trouble of manual configuration.
import { registerModels, createClient } from "@lovrabet/sdk";
// Register configuration
registerModels({
appCode: "your-app-code",
models: [
{
datasetCode: "8d2dcbae08b54bdd84c00be558ed48df",
tableName: "users",
alias: "users",
},
],
});
// Create client
const client = createClient();
// Standard access method (recommended)
const users = await client.models.dataset_8d2dcbae08b54bdd84c00be558ed48df.filter();
const user = await client.models.dataset_8d2dcbae08b54bdd84c00be558ed48df.create({
name: "John",
email: "john@example.com",
});
Model Access Methods v1.2.0+
The SDK supports two access methods with identical functionality:
// Standard method (recommended) - uses dataset_ prefix + datasetCode, globally unique, AI-friendly
const users = await client.models.dataset_8d2dcbae08b54bdd84c00be558ed48df.filter();
// Alias method (syntactic sugar) - uses configured alias, human-readable
const users = await client.models.users.filter();
Aliases are just syntactic sugar; internally, datasetCode is still used for access. The standard method is recommended because AI tools can precisely locate models when generating code.
Design Philosophy
The Lovrabet TypeScript SDK adheres to the following design principles:
- Simplicity first - Clean API design to reduce the learning curve
- Type safety - Complete TypeScript support for compile-time error detection
- Performance optimization - Built-in multiple performance optimization strategies
- Flexible configuration - Supports multiple configuration methods to adapt to different project needs
- Developer-friendly - Detailed error messages and debugging tools
Ecosystem
The Lovrabet TypeScript SDK is an important part of the Rabetbase ecosystem:
- Lovrabet CLI - Scaffolding tool for auto-generating SDK configuration
- Lovrabet Templates - Ready-to-use project templates
- OpenAPI - Rich backend data services
Getting Help
- Documentation - Check the detailed usage documentation and examples
- Community Support - Join the developer community for discussions
- Bug Reports - Report bugs promptly when found
- Technical Support - Enterprise users can get professional technical support
Start your Lovrabet TypeScript SDK journey!