nano-auth
v0.2.1
Published
A super lightweight auth library for NextJS.
Maintainers
Readme
nano-auth
A super lightweight auth library for NextJS.
Currently supports the following OAuth providers:
- Discord
- GitHub
- Microsoft
Installation
$ npm i nano-authBasic usage
auth.ts
import { createAuthInterface } from 'nano-auth';
const auth = createAuthInterface({
secretKey: process.env.SECRET,
endpointUri: 'https://mywebsite.com/authenticate',
errorUri: '/sign-in',
providers: {
google: {
clientId: '..',
secret: process.env.GOOGLE_SECRET
}
},
async retrieveUser(id: string) {
..
},
async createUser({ id, email, fullName, verified }) {
..
}
});
export const { authEndpoint, .. } = auth;app/authenticate/route.ts
import { authEndpoint } from "@/lib/auth";
export const GET = authEndpoint;