lucia-auth / lucia

Authentication, simple and clean
https://lucia-auth.com
MIT License
8.32k stars 447 forks source link

[Docs]: typo in docs, related to nextJs #1577

Closed skorphil closed 1 month ago

skorphil commented 1 month ago

Description

In nextJs tutorial there is error here https://lucia-auth.com/tutorials/username-and-password/nextjs-app#:~:text=const%20lucia%20%3D-,new%20Lucia(),-%3B%0A%0Aexport%20const

export const lucia = new Lucia();

previously in tutorial we already created lucia object with database adapter: https://lucia-auth.com/tutorials/username-and-password/nextjs-app#:~:text=const%20lucia%20%3D-,new%20Lucia,-(adapter%2C

export const lucia = new Lucia(adapter, {
    sessionCookie: {
        expires: false,
        attributes: {
            secure: process.env.NODE_ENV === "production"
        }

Finally, need to be edited:

import { cookies } from "next/headers";
import { cache } from "react";
+ import { lucia } from "@lib/auth"
import type { Session, User } from "lucia";

- export const lucia = new Lucia();

export const validateRequest = cache(
...
pilcrowOnPaper commented 1 month ago

I don't see this as a typo per-se. The second Lucia is just referencing the first one. You can either declare validateRequest() next to Lucia or in a different file.

skorphil commented 1 month ago

@pilcrowOnPaper Well, it is just not working if you copy- paste that code, following the docs.

Maybe im missing something but what is the point of creating a new empty Lucia? It needs to be created with a db adapter(which is done earlier in the tutorial)

pilcrowOnPaper commented 1 month ago

It’s just a placeholder for your Lucia instance