1.0.1 • Published 11 months ago

lucia-auth-adapter-surrealdb v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

lucia-auth-adapter-surrealdb

SurrealDB adapter for Lucia

Lucia documentation

Changelog

Installation

npm install lucia-auth-adapter-surrealdb
pnpm install lucia-auth-adapter-surrealdb
yarn add lucia-auth-adapter-surrealdb

Usage

// 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 versionLucia version
v0.8.0v1.8.0

Testing

Add your .env file with your configuration

SURREALDB_URL=
SURREALDB_USER=
SURREALDB_PASS=
SURREALDB_NS=
SURREALDB_DB=
pnpm run test-main
1.0.1

11 months ago

1.0.0

11 months ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago