gschurck / sveltekit-auth-neo4j-example

SvelteKit Auth example with Auth.js and Neo4j

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fork of the official SvelteKit Auth example for Auth.js


SvelteKit Auth Neo4j - Example App

Open Source. Full Stack. Own Your Data.

npm Bundle Size Downloads TypeScript

Overview

This is a fork of the official SvelteKit Auth example for Auth.js, to show how to use it with Neo4j adapter.

Neo4j Adapter

// hooks.server.ts

import { SvelteKitAuth } from "@auth/sveltekit"
import GitHub from "@auth/core/providers/github"
import { GITHUB_ID, GITHUB_SECRET, NEO4J_PASSWORD, NEO4J_URI, NEO4J_USER } from "$env/static/private"
import neo4j from "neo4j-driver"
import { Neo4jAdapter } from "@next-auth/neo4j-adapter"

const driver = neo4j.driver(
  NEO4J_URI,
  neo4j.auth.basic(NEO4J_USER, NEO4J_PASSWORD)
)

const neo4jSession = driver.session()
export const handle = SvelteKitAuth({
  providers: [GitHub({ clientId: GITHUB_ID, clientSecret: GITHUB_SECRET })],
  adapter: Neo4jAdapter(neo4jSession),
})

The adapter automatically synchronizes users with the Neo4j database on login :

image

About

SvelteKit Auth example with Auth.js and Neo4j

License:ISC License


Languages

Language:Svelte 66.1%Language:JavaScript 15.3%Language:TypeScript 11.5%Language:HTML 4.2%Language:Shell 2.9%