Skip to content

Commit

Permalink
feat: add support for LibSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Nov 8, 2024
1 parent 893252b commit e345fdc
Show file tree
Hide file tree
Showing 6 changed files with 297 additions and 27 deletions.
37 changes: 34 additions & 3 deletions docs/content/docs/1.getting-started/3.configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,54 @@ export default defineNuxtConfig({
})
```


### `Postgres`

If you plan to deploy your application using PostgreSql database you need to use `postgres` database adapter.
If you plan to deploy your application using PostgreSql database you need to use `postgres` database adapter.

First, make sure to install the `pg` package:

```bash [Terminal]
npx nypm i pg
```

Then, configure the `postgres` adapter in your `nuxt.config.ts`:

```ts [nuxt.config.ts]
export default defineNuxtConfig({
content: {
database: {
type: 'postgres',
url: 'POSTGRES_URL',
url: process.env.POSTGRES_URL,
/* Other options for `pg` */
}
}
})
```

### `LibSQL` / `Turso`

If you plan to deploy your application using LibSQL/Turso database you need to use `libsql` database adapter.

First, make sure to install the `@libsql/client` package:

```bash [Terminal]
npx nypm i @libsql/client
```

Then, configure the `libsql` adapter in your `nuxt.config.ts`:

```ts [nuxt.config.ts]
export default defineNuxtConfig({
content: {
database: {
type: 'libsql',
url: process.env.TURSO_DATABASE_URL,
authToken: process.env.TURSO_AUTH_TOKEN,
}
}
})
```

## `build`

Nuxt Content read and parse all the available contents at built time. This option let you control over parsing contents.
Expand Down
7 changes: 5 additions & 2 deletions docs/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ export default defineNuxtConfig({

content: {
database: {
type: 'd1',
binding: 'DB',
// type: 'd1',
// binding: 'DB',
type: 'libsql',
url: process.env.TURSO_DATABASE_URL!,
authToken: process.env.TURSO_AUTH_TOKEN!,
},
},

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
"zod-to-ts": "^1.2.0"
},
"peerDependencies": {
"pg": "*"
"pg": "*",
"@libsql/client": "*"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20241106.0",
Expand Down
Loading

0 comments on commit e345fdc

Please sign in to comment.