Docs

Auth

Using EIP-4361 (Sign in with Ethererum) standard, you can authenticate users to your backend using only their wallet. This is a secure and easy way to authenticate users without requiring them to create an additional account.

Example Repo

Auth + Next.js

A working example of Auth + Next.js

Usage

import { createAuth } from 'thirdweb/auth';
const auth = createAuth({...});
// 1. generate a login payload for a client on the server side
const loginPayload = await auth.generatePayload({ address: '0x123...' });
// 2. send the login payload to the client to sign
// 3. verify the login payload and signature that the client sends back later
const verifiedPayload = await auth.verifyPayload({ payload: loginPayload, signature: '0x123...' });
// 4. generate a JWT for the client
const jwt = await auth.generateJWT({ payload: verifiedPayload });
// 5. set the JWT as a cookie or otherwise provide it to the client
// 6. authenticate the client based on the JWT on subsequent calls
const { valid, parsedJWT } = await auth.verifyJWT({ jwt });