authli
v1.0.2
Published
A quick library to implement basic auth for user register/login, including a server action. For Prisma + NextJS.
Downloads
4
Readme
Easiest way to login with Next js
Register a user
const user = { email: "[email protected]", password: "password" }; // Your user must have an email and password field
await registerUser(user, prisma); // Generate your prisma client and pass it as props
Login a user
const user = { email: "[email protected]", password: "password" }; // Your user must have an email and password field
await loginUser(user, prisma); // Generate your prisma client and pass it as props
Using forms with server actions
<form action={async (data: FormData) => { try {
await authForm(data)
} catch (error) {
// Handle the error
} }}>
<input name="email" />
<input name="password" />
<input name="confirm-password" /> <!-- If on the create user page -->
</form>