Bridge SDK
A Bridge is a data source adapter. It tells SemiLayer how to connect to a specific source, read records in pages, and count them. Bridges are the only place SemiLayer touches your data — and it only ever reads.
SemiLayer ships first-party bridges for 20+ data sources — every major relational, document, key-value, analytics, and search engine. They all live in the semilayer/bridge-sdk monorepo alongside the SDK itself and the contribution tooling. See the Ecosystem section below for the full list.
The Bridge Interface
Every bridge must implement this interface, defined in @semilayer/core
(re-exported from @semilayer/bridge-sdk):
Key Types
Compliance Test Suite
Every bridge should pass the compliance test suite provided by @semilayer/bridge-sdk.
The suite verifies the Bridge contract: connect/disconnect, read pagination, cursor
behavior, count, and (if implemented) query.
The BridgeTestSuiteOptions shape:
| Field | Type | Description |
|---|---|---|
factory | () => Bridge | Factory called before each test group |
seed.target | string | Target name (table, collection, etc.) |
seed.rows | BridgeRow[] | Records the test suite will read and verify |
seed.primaryKey | string | PK field name used for cursor overlap checks |
beforeSeed? | (bridge) => Promise<void> | Called after connect, before data is verified |
afterCleanup? | (bridge) => Promise<void> | Called after disconnect for teardown |
Run the suite with pnpm test. All tests must pass before a bridge is eligible for
inclusion in the built-in registry.
MockBridge
MockBridge is an in-memory bridge for unit testing your application code without a
real connection. It fully implements the Bridge interface including query.
Building a Bridge
1. Scaffold from the template
Clone the bridge monorepo and use the scaffold script:
The script scaffolds packages/bridge-<name>/src/bridge.ts with interface stubs,
creates a compliance test file, and registers the package in the release manifest.
2. Implement the interface
Open packages/bridge-<name>/src/bridge.ts and implement the four required methods:
connect, read, count, disconnect. Add query if you want direct-source queries.
Tips:
- Use cursor-based (keyset) pagination in
read(). Offset-based pagination is unreliable on large sources with concurrent writes. - Keep the default connection pool size small (3–5). The worker may run many ingest jobs concurrently.
- Validate config in
connect(). Fail early with a clear error rather than mid-ingest. count()is called for progress reporting. Keep it cheap if possible.
3. Run the compliance suite
All tests must pass before submitting.
4. Register in the built-in registry
Open lib/bridge-resolver/src/index.ts and add your bridge:
Add it as a workspace:* dependency in lib/bridge-resolver/package.json:
5. Submit a PR
Open a PR against semilayer/bridge-sdk. Include:
- The new
packages/bridge-<name>/directory - The registry update in
lib/bridge-resolver/ - A passing CI run (GitHub Actions runs the compliance suite against a real source)
- A brief description of the data source and any notable behaviors or limitations
Review SLA is 2 weeks. We'll leave feedback or merge.
Release Pipeline
Merging the PR triggers release-please to open a release PR. Merging the release PR
publishes both @semilayer/bridge-<name> and a bumped @semilayer/bridge-resolver
to npm atomically. The node-workspace plugin handles the version ripple automatically.
Once @semilayer/bridge-resolver is published with your bridge, deployments that
bump their bridge-resolver dependency pick it up automatically.
Private & Enterprise Bridges
Enterprise deployments that need a private bridge (proprietary source, internal code) use runtime registration rather than the public registry:
Call registerBridge at worker startup, before the first ingest job runs. The bridge
is available for that deployment only — the public registry is unaffected.
Reference Implementation
@semilayer/bridge-postgres is the reference implementation. It's the most complete
bridge and the best one to study when building your own.
- Location:
packages/bridge-postgres/insemilayer/bridge-sdk - Connection pooling:
pg.Poolwithmax: 3 - Pagination: keyset pagination via primary key (
WHERE pk > $cursor ORDER BY pk ASC) - Incremental:
changedSince+changeTrackingColumnsupport - Query: full
WHERE,ORDER BY,LIMIT,OFFSETsupport with operators ($eq,$gt,$gte,$lt,$lte,$in) - Introspection:
listTargets()andintrospectTarget()for Console source setup
Ecosystem
SemiLayer ships first-party bridges across every major category. All of them live in the
semilayer/bridge-sdk monorepo and are published to npm under the @semilayer/ scope.
Relational SQL
| Bridge | Package |
|---|---|
| PostgreSQL | @semilayer/bridge-postgres |
| MySQL | @semilayer/bridge-mysql |
| MariaDB | @semilayer/bridge-mariadb |
| SQLite | @semilayer/bridge-sqlite |
| Microsoft SQL Server | @semilayer/bridge-mssql |
| Oracle | @semilayer/bridge-oracle |
| CockroachDB | @semilayer/bridge-cockroachdb |
Cloud / Edge SQL
| Bridge | Package |
|---|---|
| Neon | @semilayer/bridge-neon |
| Turso | @semilayer/bridge-turso |
| PlanetScale | @semilayer/bridge-planetscale |
| Cloudflare D1 | @semilayer/bridge-d1 |
| Supabase | @semilayer/bridge-supabase |
Document
| Bridge | Package |
|---|---|
| MongoDB | @semilayer/bridge-mongodb |
| Firestore | @semilayer/bridge-firestore |
Key-Value
| Bridge | Package |
|---|---|
| Redis | @semilayer/bridge-redis |
| Upstash | @semilayer/bridge-upstash |
AWS
| Bridge | Package |
|---|---|
| DynamoDB | @semilayer/bridge-dynamodb |
Analytics
| Bridge | Package |
|---|---|
| ClickHouse | @semilayer/bridge-clickhouse |
| BigQuery | @semilayer/bridge-bigquery |
| DuckDB | @semilayer/bridge-duckdb |
| Snowflake | @semilayer/bridge-snowflake |
Search / Wide-column
| Bridge | Package |
|---|---|
| Elasticsearch | @semilayer/bridge-elasticsearch |
| Cassandra | @semilayer/bridge-cassandra |
Don't see your data source? See the scaffold instructions above and open a PR. We welcome bridges for any data source — SQL databases, NoSQL stores, REST APIs, file systems, message queues, or anything you can read from.