Skip to main content

Overview

While Supabase is the recommended storage provider, you can create custom adapters for any database system. This guide shows how to implement the IStorageAdapter interface for your preferred database.

IStorageAdapter Interface

All storage adapters must implement this interface:

Example: MongoDB Adapter

Here’s a complete example of a MongoDB storage adapter:

Usage


Example: PostgreSQL Adapter

Using pg library for PostgreSQL:

Message Transformers

Transform messages before storing them in the database:

Testing Your Adapter

Create comprehensive tests for your custom adapter:

Best Practices

1. Connection Pooling

Use connection pools for better performance:

2. Error Handling

Implement robust error handling:

3. Indexing

Create appropriate indexes for performance:

4. Batch Operations

Support batch inserts for better performance:

Next Steps

Supabase Setup

See the recommended Supabase implementation

Query Data

Learn how to query stored messages

Best Practices

Storage security and performance tips

API Reference

Complete SDK API documentation