# Migrate from Cloudflare D1 to Layerbase

> Move a Cloudflare D1 database to managed libSQL on Layerbase. Reachable from any runtime, not just Workers. Exact SQLite type fidelity, flat pricing.

Canonical: https://layerbase.com/migrate/cloudflare-d1
Platform limits verified: 2026-11-01. Generated from Layerbase source: 2026-11-25

Move a D1 database to managed libSQL on Layerbase in one guided pass. Paste your Cloudflare account ID and an API token, pick a database, and we copy the schema and data with every SQLite type intact. Your D1 keeps serving traffic the whole time.

## Key facts

| Fact | Value |
| --- | --- |
| Source platform | Cloudflare D1 |
| Layerbase target engines | libSQL |
| How you connect | Connect your account with an API key |
| Source modified | No: read-once copy, credentials never stored |

## Why switch from Cloudflare D1

### Reachable from anywhere, not just Workers

D1 is designed to be read from a Cloudflare Worker. Layerbase libSQL is an HTTPS endpoint with an auth token, so the same database serves a Worker, a Vercel function, a container, a cron job, or your laptop.

### We do not use D1 exports, on purpose

A SQL dump renders every number through JavaScript, which quietly rounds any integer past 2^53. We read your rows over the query API with the encoding done inside SQLite, so an int64 id arrives exactly as stored. Cloudflare documents the precision limit; we route around it.

### No read or write metering

D1 bills rows read and rows written. A Layerbase libSQL database costs the same whatever your traffic does, on flat plans with a free tier. A busy day stops being a billing question.

### A database with a dashboard

Web SQL console, backups, TLS by default, and branching, sitting next to your Postgres, Redis and everything else in one account rather than in another provider tab.

## Cloudflare D1 and Layerbase limits

| Limit | Cloudflare D1 | Layerbase |
| --- | --- | --- |
| Concurrent queries | One query at a time per database | Reads run in parallel; writes take turns, as in any SQLite |
| Largest row, string or blob | 2 MB | About 5 MB per value |
| Bound parameters per query | 100 | 32,766 |
| Columns per table | 100 | 2,000 |
| SQL statement length | 100 KB | No 100 KB cap (a 500 KB statement runs) |
| LIKE or GLOB pattern | 50 bytes | 50,000 bytes |
| Arguments per SQL function | 32 | 127 |
| Database size | 10 GB, cannot be increased | Set by your plan storage, raised with Pro pool blocks or a dedicated server |
| Who can connect | A Worker binding, or the REST API | Any runtime, over HTTPS with an auth token |
| Billing | Rows read and rows written, index updates counted as writes | Flat plans, no per-row meter |
| Spending cap | None on Workers Paid | Not needed: the price does not move with usage |

Cloudflare D1 values read from https://developers.cloudflare.com/d1/platform/limits/ on 2026-11-01. Layerbase values measured on libSQL server 0.24.32, the version Layerbase Cloud runs.

Where Cloudflare D1 is stronger:

- Read replicas close to users on every continent. A Layerbase database lives in one region.
- Thousands of databases per account. Layerbase counts databases per plan.

## How the migration works

1. **Create a free account or sign in.** Sign in with Google or GitHub. No credit card is needed to start, and the migration wizard opens with this platform already selected.
2. **Connect your account.** Paste your Cloudflare account ID (Workers and Pages overview, or the /accounts/<id> segment of your dashboard URL) and an API token with D1 Read on that account (My Profile, then API Tokens). We list your D1 databases so you can pick one, then copy its schema and data into a new managed libSQL database, preserving every SQLite type.
3. **Pick what to migrate and name it.** Choose what to bring over, give the new Layerbase database a name, and start the migration. Progress streams live in the dashboard.
4. **We copy it in one pass.** The migration reads from Cloudflare D1 once and never writes to it. Credentials are used for the copy and never stored. When it finishes, you land in your new database with a live TLS connection string.

## Common Cloudflare D1 migration questions

### What credentials do I need?

Your Cloudflare account ID and an API token with the D1 Read permission, scoped to that account. Create it under My Profile, then API Tokens, as a custom token. A Global API Key will not work: it is not a bearer token. We list the D1 databases on the account so you pick one rather than hunting for an id.

### Does the migration change or pause my D1 database?

No. The importer only issues read statements, and reads do not block D1, so your Worker keeps serving traffic while the copy runs. Note this also means the copy is not a single point-in-time snapshot: we compare row counts before and after and tell you if anything was written mid-copy.

### Do large integers and blobs survive exactly?

Yes, and that is the reason for the approach. Integers cross the wire as exact decimal text, floats through a full-precision format, and text and blobs as hex, so nothing numeric is ever routed through a JavaScript number. Snowflake ids, nanosecond timestamps and bitfields come across unchanged.

### What about generated columns and full-text search?

Generated columns are detected and left for libSQL to recompute, so they stay generated rather than becoming frozen values. Full-text search tables are recreated, but their index content is not copied: rebuild those after the import and the migration report tells you which ones.

### Does my application code change?

You swap the D1 binding for a libSQL client. On Drizzle that is a one-line driver change from the D1 driver to the libSQL one. The SQL itself does not change, because libSQL is SQLite.

## Links

- [Migrate from Cloudflare D1](https://layerbase.com/migrate/cloudflare-d1)
- [libSQL on Layerbase](https://layerbase.com/db/libsql) (markdown: https://layerbase.com/db/libsql.md)
- [Cloud migration guide](https://layerbase.com/docs/cloud/migrate)
- [Pricing](https://layerbase.com/pricing) (markdown: https://layerbase.com/pricing.md)
