React + Vite example using MetaMask Embedded Wallets (powered by Web3Auth) with a bring-your-own JWT backend. You issue the JWT from your own server; Web3Auth validates it via your JWKS endpoint and derives the user's wallet. Compatible with any OAuth 2.0 / OIDC-compliant identity provider.
The JWT must include an
iatclaim within 60 seconds of the current time on every login attempt, regardless ofexp.
- Node.js 20+
- npm
- A Client ID from the Dashboard
- Your own JWT issuer with a publicly accessible JWKS endpoint
- A custom JWT connection configured on the Dashboard (Custom JWT guide)
git clone https://github.com/Web3Auth/web3auth-examples.git
cd web3auth-examples/custom-authentication/single-connection/custom-jwt-examplenpm installIn a separate terminal, start the demo JWT server:
cd server
npm install
npm startThe server runs at http://localhost:8080 by default and exposes /api/token.
cp .env.example .envEdit .env:
VITE_WEB3AUTH_CLIENT_ID=YOUR_CLIENT_ID
Optional — override the JWT server URL (defaults to http://localhost:8080):
VITE_JWT_SERVER_URL=http://localhost:8080
npm run devVisit http://localhost:5173 in your browser.
- MetaMask Embedded Wallets Documentation
- Build with AI — set up the MCP server and skill for AI-assisted integration
- Custom JWT Guide
- Dashboard
- Community — Builder Hub
MIT