https://github.com/fernandolguevara/lucia-auth-adapter-surrealdb
lucia-auth-adapter-surrealdb
https://github.com/fernandolguevara/lucia-auth-adapter-surrealdb
Last synced: 12 months ago
JSON representation
lucia-auth-adapter-surrealdb
- Host: GitHub
- URL: https://github.com/fernandolguevara/lucia-auth-adapter-surrealdb
- Owner: fernandolguevara
- Created: 2022-11-12T16:41:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-13T00:59:18.000Z (almost 3 years ago)
- Last Synced: 2025-04-15T00:18:14.147Z (about 1 year ago)
- Language: TypeScript
- Size: 11.7 KB
- Stars: 6
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# `lucia-auth-adapter-surrealdb`
[SurrealDB](https://surrealdb.com/) adapter for Lucia
**[Lucia documentation](https://lucia-auth.vercel.app)**
**[Changelog](https://github.com/fernandolguevara/lucia-auth-adapter-surrealdb/CHANGELOG.md)**
## Installation
```
npm install lucia-auth-adapter-surrealdb
pnpm install lucia-auth-adapter-surrealdb
yarn add lucia-auth-adapter-surrealdb
```
## Usage
```js
// required imports
import lucia from "lucia-auth";
import surrealdb from "lucia-auth-adapter-surrealdb";
// init surrealdb adapter
const adapter = surrealdb({
uri: "surrealdb-uri", // Example: 'http://localhost:8000/rpc',
user: "surrealdb-user",
pass: "surrealdb-pass",
ns: "my-ns",
db: "my-db",
});
// init lucia using the adapter
const auth = lucia({
adapter,
env: "DEV",
});
// OR
// only if you want to build the surrealdb client yoursef
import Surreal from "$lib/surreal";
// build and init surrealdb client
const surreal = new Surreal("surrealdb-uri");
await surreal.signin({
user: "surrealdb-user",
pass: "surrealdb-pass",
});
await surreal.use("my-ns", "my-db");
// init lucia passing surrealdb client to the adapter
const adapter = surrealdb({
surreal,
});
// init lucia using the adapter
const auth = lucia({
adapter,
env: "DEV",
});
export type Auth = typeof auth;
// enjoy
```
## Lucia version compatibility
| Surrealdb adapter version | Lucia version |
| ------------------------- | ------------- |
| v0.8.0 | v1.8.0 |
## Testing
Add your .env file with your configuration
```
SURREALDB_URL=
SURREALDB_USER=
SURREALDB_PASS=
SURREALDB_NS=
SURREALDB_DB=
```
```
pnpm run test-main
```