nano-auth
v0.3.0
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:
- Apple
- Discord
- GitHub
- Microsoft
Installation
$ npm i nano-authBasic usage
auth.ts
import { createAuthInterface } from 'nano-auth';
const auth = createAuthInterface({
secretKey: process.env.SECRET,
endpointUrl: 'https://mywebsite.com/authenticate',
errorUrl: '/sign-in',
providers: {
google: {
clientId: '..',
secret: process.env.GOOGLE_SECRET
},
apple: {
clientId: '..',
secret: process.env.APPLE_CLIENT_SECRET // Signed ES256 JWT generated using .p8 key file
}
},
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;
export const POST = authEndpoint; // Only required if you support Apple as a provider