Skip to main content
Home

Built and signed on GitHub Actions

The unofficial SurrealDB adapter for Lucia auth. The robust and easy-to-use authentication solution for modern web applications.

This package works with Node.js, Deno, BunIt is unknown whether this package works with Cloudflare Workers, Browsers
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
It is unknown whether this package works with Browsers
JSR Score
100%
Published
7 months ago (0.3.2)
Caution


Lucia-auth is deprecated, and turns into the learning resource. If you are looking for comprehensive authentication framework for TypeScript, I recommend Better-Auth and I recommend to use it with surreal-better-auth adapter that allow you to use Better-Auth with SurrealDB! BTW. Grab your free SurrealDB Instance with something extra from ✨THAT LINK✨ . This package (surreal-lucia) is not maintained anymore, and this repo will be archived soon.

SurrealDB Adapter for Lucia

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

Feedback

⭐ Found this project helpful? Show some love with a star and consider to be a SPONSOR! Your support keeps the code evolving. 🚀

Free Database

✨ Grab FREE SurrealDB Cloud instance 🚀🚀🚀

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.

Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@oskargmerek/surreal-lucia

Import symbol

import * as surreal_lucia from "@oskargmerek/surreal-lucia";
or

Import directly with a jsr specifier

import * as surreal_lucia from "jsr:@oskargmerek/surreal-lucia";

Add Package

pnpm i jsr:@oskargmerek/surreal-lucia
or (using pnpm 10.8 or older)
pnpm dlx jsr add @oskargmerek/surreal-lucia

Import symbol

import * as surreal_lucia from "@oskargmerek/surreal-lucia";

Add Package

yarn add jsr:@oskargmerek/surreal-lucia
or (using Yarn 4.8 or older)
yarn dlx jsr add @oskargmerek/surreal-lucia

Import symbol

import * as surreal_lucia from "@oskargmerek/surreal-lucia";

Add Package

vlt install jsr:@oskargmerek/surreal-lucia

Import symbol

import * as surreal_lucia from "@oskargmerek/surreal-lucia";

Add Package

npx jsr add @oskargmerek/surreal-lucia

Import symbol

import * as surreal_lucia from "@oskargmerek/surreal-lucia";

Add Package

bunx jsr add @oskargmerek/surreal-lucia

Import symbol

import * as surreal_lucia from "@oskargmerek/surreal-lucia";