Skip to content

This adapter seamlessly integrates SurrealDB with Lucia, providing a robust and easy-to-use authentication solution for modern applications.

License

Notifications You must be signed in to change notification settings

oskar-gmerek/surreal-lucia

Repository files navigation

SurrealDB Adapter for Lucia

This adapter seamlessly integrates SurrealDB with Lucia, providing a robust and easy-to-use authentication solution for modern applications.

Modern Technology

SurrealDB

Lucia auth

Requirements

Note

Package installation examples use bun as the package manager, but you can replace bun with npm, yarn, pnpm, or deno.

Installation

Note

Depending on your package manager, you can replace bunx with npx, yarn dlx, pnpm dlx, or use deno add.

bunx jsr add @oskargmerek/surreal-lucia

Setup Example

Important

This example shows how to implement a SurrealDB adapter for Lucia. It is not an example of the full authentication, nor authorization setup. You should be familiar with the Lucia documentation, which contains a framework-specific guides. Read the Lucia Documentation for more information.

import { Lucia } from "lucia";
import { SurrealDBLuciaAdapter } from "@oskargmerek/surreal-lucia";

// initialize SurrealDB
const db = new Surreal(); 

// initialize adapter
const adapter = new SurrealDBLuciaAdapter(db, {
  sessionTableName: 'sessions', 
  userTableName: 'users', 
}); 

// initialize Lucia with SurrealDB adapter
export const lucia = new Lucia(adapter, {
	sessionCookie: {
		attributes: {
			// set to `true` when using HTTPS
			secure: process.env.NODE_ENV === "production"
		}
	}
});

// IMPORTANT!
declare module "lucia" {
    interface Register {
      Lucia: typeof lucia;
      DatabaseUserAttributes: {
        username: string; // example of an additional optional attribute
      },
      DatabaseSessionAttributes: {
        device: string // example of an additional optional attribute
    }
  }
}

Documentation

License

This adapter is distributed under the MIT License. Please refer to the LICENSE file for more information.

About

This adapter seamlessly integrates SurrealDB with Lucia, providing a robust and easy-to-use authentication solution for modern applications.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published