@@ -28,6 +28,21 @@ drizzle-orm @libsql/client
28
28
</Npm >
29
29
30
30
#### 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" ]} >
31
46
``` typescript copy
32
47
import { drizzle } from ' drizzle-orm/libsql' ;
33
48
@@ -38,9 +53,61 @@ const db = drizzle({ connection: {
38
53
39
54
const result = await db .select ().from (... )
40
55
```
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 >
41
107
42
108
If you need to provide your existing driver:
43
109
110
+ <CodeTabs items = { [" default" , " web" ]} >
44
111
``` typescript copy
45
112
import { drizzle } from ' drizzle-orm/libsql' ;
46
113
import { createClient } from ' @libsql/client' ;
@@ -54,6 +121,20 @@ const db = drizzle({ client });
54
121
55
122
const result = await db .select ().from (users ).all ()
56
123
```
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 >
57
138
58
139
#### What's next?
59
140
0 commit comments