According to the official website,
Turso is a libSQL powered edge SQLite database as a service.
Drizzle ORM natively supports libSQL driver,
we embrace SQL dialects and dialect specific drivers and syntax and mirror most popular
SQLite-like all, get, values and run query methods syntax.
npm
yarn
pnpm
bun
Unless you plan on writing every SQL query by hand, a table declaration is helpful:
According to the official website,
D1 is Cloudflare’s first queryable relational database.
Drizzle ORM fully supports the Cloudflare D1 database and Cloudflare Workers environment.
We embrace SQL dialects and dialect specific drivers and syntax and mirror most popular
SQLite-like all, get, values and run query methods syntax.
To setup project for your Cloudflare D1 please refer to official docs.
Initialize local database and run server locally:
Install Drizzle ORM:
npm
yarn
pnpm
bun
Make your first D1 query:
Unless you plan on writing every SQL query by hand, a table declaration is helpful:
According to the official website, Bun is a fast all-in-one JavaScript runtime.
Drizzle ORM natively supports bun:sqlite module and it’s crazy fast 🚀
We embraces SQL dialects and dialect specific drivers and syntax and unlike any other ORM,
for synchronous drivers like bun:sqlite we have both async and sync APIs and we mirror most popular
SQLite-like all, get, values and run query methods syntax.
npm
yarn
pnpm
bun
Unless you plan on writing every SQL query by hand, a table declaration is helpful:
More on sync and async APIs for sqlite - read here.
Expo SQLite
According to the official website, Expo is an ecosystem of tools to develop, build and ship applications on React Native.
It’s powered by Hermes JavaScript runtime and Metro bundler, Drizzle Expo driver is built to natively support both.
Drizzle ORM has the best in class toolkit for Expo SQLite:
Native ORM driver for Expo SQLite ✅
Drizzle Kit support for migration generation and bundling in application ✅
Drizzle Studio dev tools plugin to browse on device database ✅
Live Queries ✅
npm
yarn
pnpm
bun
Live Queries
With useLiveQuery hook you can make any Drizzle query reactive:
Expo SQLite migrations with Drizzle Kit
You can use Drizzle Kit for SQL migration generation.
Please make sure to check how Drizzle Kit migrations work before proceeding.
Expo / React Native requires you to have SQL migrations bundled into the app and we’ve got you covered.
Install babel plugin
It’s necessary to bundle SQL migration files as string directly to your bundle.
Update config files.
You will need to update babel.config.js, metro.config.js and drizzle.config.ts files
Make sure to have dialect: 'sqlite' and driver: 'expo' in Drizzle Kit config
Generate migrations
After creating SQL schema file and drizzle.config.ts file, you can generate migrations
Add migrations to your app
Now you need to import migrations.js file into your Expo/React Native app from ./drizzle folder.
You can run migrations on application startup using our custom useMigrations migrations hook on in useEffect hook manually as you want.
OP SQLite
According to the official github page,
OP-SQLite embeds the latest version of SQLite and provides a low-level API to execute SQL queries.
npm
yarn
pnpm
bun
You can use Drizzle Kit for SQL migration generation.
Please make sure to check how Drizzle Kit migrations work before proceeding.
OP SQLite requires you to have SQL migrations bundled into the app and we’ve got you covered.
Install babel plugin
It’s necessary to bundle SQL migration files as string directly to your bundle.
Update config files.
You will need to update babel.config.js, metro.config.js and drizzle.config.ts files
Make sure to have dialect: 'sqlite' and driver: 'expo' in Drizzle Kit config
Generate migrations
After creating SQL schema file and drizzle.config.ts file, you can generate migrations
Add migrations to your app
Now you need to import migrations.js file into your Expo/React Native app from ./drizzle folder.
You can run migrations on application startup using our custom useMigrations migrations hook on in useEffect hook manually as you want.
React Native SQLite
Please use Expo SQLite to run Drizzle ORM with React Native apps.
The only popular library we’ve found does not support new Hermes JavaScript runtime,
which is a standard out of the box runtime for React Native and Expo now.
better-sqlite3
According to the official docs,
BetterSqlite3 is the fastest and simplest library for SQLite3 in Node.js.
Drizzle ORM embraces SQL dialects and dialect specific drivers and syntax and unlike any other ORM,
for synchronous drivers like better-sqlite3 both async and sync APIs and we mirror most popular
SQLite-like all, get, values and run query methods syntax.
npm
yarn
pnpm
bun
Unless you plan on writing every SQL query by hand, a table declaration is helpful: