This document explains how to implement Privy authentication in a full-stack JavaScript application, including JWT verification and protected API endpoints.
The implementation consists of three main parts:
- Client-side authentication with Privy
- Server-side JWT verification
- Protected API endpoints
- Privy account and API credentials
- Node.js and npm
- SQLite for data storage
Copy the .env.example file to .env and fill in the values.
This example uses SQLite for simplicity. This can be replaced in production with MongoDB,
- Run
npm installto install the dependencies. - Run
npm run buildto build the site. - Run
node server.jsto start the server.
- Run
npm run devto start the development server. - Navigate to
http://localhost:3000in your browser. - Click the "Login" button to authenticate with Privy.
- Once authenticated, you should see a random number and your user ID.
- Click the "Open String Input Window" and enter a value.
- Verify in the DB (or in the server logs) that the value was stored.
User arrives at the application and sees the login button
User selects MetaMask as their authentication method
After successful authentication, user sees their random number and user ID
User enters a string value in the popup window
Server logs showing successful string submission and processing




