Skip to content

Commit 34b634b

Browse files
committed
libsql mutlidriver support
1 parent 4b30d80 commit 34b634b

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

src/content/documentation/docs/connect-turso.mdx

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ drizzle-orm @libsql/client
2828
</Npm>
2929

3030
#### Step 2 - Initialize the driver and make a query
31+
Drizzle has native support for all `@libsql/client` driver variations:
32+
33+
| | |
34+
| :----------------------- | :---------------------------------------------------------------------------------------------------------------------------------------- |
35+
| `@libsql/client` | defaults to `node` import, automatically changes to `web` if `target` or `platofrm` is set for bundler, e.g. `esbuild --platform=browser` |
36+
| `@libsql/client/node` | `node` compatible module, supports `:memory:`, `file`, `wss`, `http` and `turso` conneciton protocols |
37+
| `@libsql/client/web` | module for fullstack web frameworks like `next`, `nuxt`, `astro`, etc. |
38+
| `@libsql/client/http` | module for `http` and `https` connection protocols |
39+
| `@libsql/client/ws` | module for `ws` and `wss` conneciton protocols |
40+
| `@libsql/client/sqlite3` | module for `:memory:` and `file` conneciton protocols |
41+
| `@libsql/client-wasm` | Separate experimental package for WASM |
42+
43+
<br/>
44+
45+
<CodeTabs items={["default", "node", "web", "http", "web sockets", "wasm"]}>
3146
```typescript copy
3247
import { drizzle } from 'drizzle-orm/libsql';
3348

@@ -38,9 +53,61 @@ const db = drizzle({ connection: {
3853

3954
const result = await db.select().from(...)
4055
```
56+
```typescript copy
57+
import { drizzle } from 'drizzle-orm/libsql/node';
58+
59+
const db = drizzle({ connection: {
60+
url: process.env.DATABASE_URL,
61+
authToken: process.env.DATABASE_AUTH_TOKEN
62+
}});
63+
64+
const result = await db.select().from(...)
65+
```
66+
```typescript copy
67+
import { drizzle } from 'drizzle-orm/libsql/web';
68+
69+
const db = drizzle({ connection: {
70+
url: process.env.DATABASE_URL,
71+
authToken: process.env.DATABASE_AUTH_TOKEN
72+
}});
73+
74+
const result = await db.select().from(...)
75+
```
76+
```typescript copy
77+
import { drizzle } from 'drizzle-orm/libsql/http';
78+
79+
const db = drizzle({ connection: {
80+
url: process.env.DATABASE_URL,
81+
authToken: process.env.DATABASE_AUTH_TOKEN
82+
}});
83+
84+
const result = await db.select().from(...)
85+
```
86+
```typescript copy
87+
import { drizzle } from 'drizzle-orm/libsql/ws';
88+
89+
const db = drizzle({ connection: {
90+
url: process.env.DATABASE_URL,
91+
authToken: process.env.DATABASE_AUTH_TOKEN
92+
}});
93+
94+
const result = await db.select().from(...)
95+
```
96+
```typescript copy
97+
import { drizzle } from 'drizzle-orm/libsql/wasm';
98+
99+
const db = drizzle({ connection: {
100+
url: process.env.DATABASE_URL,
101+
authToken: process.env.DATABASE_AUTH_TOKEN
102+
}});
103+
104+
const result = await db.select().from(...)
105+
```
106+
</CodeTabs>
41107

42108
If you need to provide your existing driver:
43109

110+
<CodeTabs items={["default", "web"]}>
44111
```typescript copy
45112
import { drizzle } from 'drizzle-orm/libsql';
46113
import { createClient } from '@libsql/client';
@@ -54,6 +121,20 @@ const db = drizzle({ client });
54121

55122
const result = await db.select().from(users).all()
56123
```
124+
```typescript copy
125+
import { drizzle } from 'drizzle-orm/libsql/web';
126+
import { createClient } from '@libsql/client/web';
127+
128+
const client = createClient({
129+
url: process.env.DATABASE_URL,
130+
authToken: process.env.DATABASE_AUTH_TOKEN
131+
});
132+
133+
const db = drizzle({ client });
134+
135+
const result = await db.select().from(users).all()
136+
```
137+
</CodeTabs>
57138

58139
#### What's next?
59140

0 commit comments

Comments
 (0)