Custom Auth Server

Learn how to integrate your auth backend with our embedded wallets solution so you can onboard your users into web3 seamlessly.

This guide will show you how to create your own Auth Server that is compatible with the auth_endpoint strategy. By doing so, you can have full control over user authentication and data security. This allows you to ensure that your application meets specific compliance requirements while also providing a customized sign-in experience.

5 minute quickstart

  • Step 1

    Navigate to Wallets > Embedded Wallets in the thirdweb dashboard.

  • Step 2

    Create a thirdweb API key if you don't have one or select an existing key to use for this project. Learn more about API keys.

  • Step 3

    Allowlist domain or bundle ids in Access Restrictions.

  • Step 4

    Navigate to the Configuration view and enable Custom Auth Endpoint

  • Step 5

    Set the Auth Endpoint URL to for testing purposes. You will replace this later with your own auth server endpoint to verify the payload.

  • Step 6

    Save the configuration.
  • Step 7

    Copy the client ID.
  • Step 8

    In your preferred thirdweb client SDK, pass the payload you retrieved from logging in to the server.

You can now auth into the wallet and use it to sign transactions like so (see use your own auth for more):

In React and React Native, the useEmbeddedWallet() hook handles authentication and connection states.

import { useEmbeddedWallet } from "@thirdweb-dev/react"; // or /react-native
const embeddedWallet = useEmbeddedWallet();
const handlePostLogin = async () => {
await embeddedWallet.connect({
strategy: "auth_endpoint",
// in production this would be your public identifier for the user
payload: JSON.stringify({ userId: "ANY_RANDOM_ID_HERE" }),
encryptionKey: "your-encryption-key",

You can set your encryptionKey in either a secret env variable or ask the user to enter a password for it.

** Do not hardcode the encryptionKey in your code. **

A persistent, cross-platform wallet is now created for your user!

Of course, you would use your own auth server instead of the one we provided. The rest of this guide will show you how to create your own auth server.


The following steps will show you how to create a simple auth server that can be used with the embedded wallet.

At a high level, the auth server will:

  • Handle login for the user into your application.
  • Have a way to get a public identifier for the user.
  • Have an endpoint to verify the public identifier and return some basic information about the user

Steps 1 and 2 are up to you to implement. You can use any auth strategy you want.

The endpoint in step 3 is what your register as your auth endpoint on the thirdweb dashboard.

Here's a high level diagram:

  • Step 1

    Create a new directory for your project and navigate to it in your CLI

    mkdir custom-auth-server
    cd custom-auth-server
  • Step 2

    Initialize a new Node.js application

    npm init -y


    yarn init -y

Create the Server:

In the custom-auth-server directory, create a file at the root named server.js and paste the following:

const express = require("express");
const fs = require("fs");
const app = express();
const PORT = process.env.PORT || 3000;
const users = [{ id: 1, email: "[email protected]", password: "password123" }];
// This is what your app calls to login a user and get a public identifier for the user (otherwise known as the payload)"/login", (req, res) => {
const { email, password } = req.body;
const user = users.find((u) => === email && u.password === password);
if (!user) return res.status(401).send({ message: "Invalid credentials" });
res.send({ payload: });
// This is a sample endpoint that yuou would register on the thirdweb dashboard for us to verify the payload
app.get("/thirdweb-will-call-this", (req, res) => {
const { payload } = req.body;
if (!payload) return res.status(401).send({ message: "Invalid credentials" });
// you would write your own logic here to verify the payload here
const user = users.find((u) => === payload);
if (!user) return res.status(401).send({ message: "Invalid credentials" });
// once the user is successfully verified, you can return the following field
return res.send({
// the last two fields here are optional
exp: Math.floor( / 1000) + 60 * 60 * 24 * 30,
app.listen(PORT, () => {
console.log(`Server started on port ${PORT}`);

Test Locally

  • Start the server:

    node server.js
  • Test login:

    curl -X POST http://localhost:3000/login -H "Content-Type: application/json" -d '{"email": "[email protected]", "password": "password123"}'


To deploy the server, you can use use services such as Zeet or Docker.

Integrate Embedded Wallets

Refer top the quickstart above to integrate the embedded wallet into your application.