Option 1: Leverage NextAuth
If you are using Next.js, you can easily integrate the NextAuth library with Dynamic to perform server-side verification and then use a session client-side.Option 2: Leverage Passport.js
We offer an official passport-dynamic extension.Option 3: Do-It-Yourself Verification
- Get the JWT through the Dynamic SDK with an authToken.
- Send the authToken to the server as a Bearer token
- Install the node-jsonwebtoken and jwks-rsa packages
- Validate the JWT on your server by fetching the public key from the JWKS endpoint API endpoint and verifying the encoded JWT against the public key:
- jwks-rsa: Provides client to interact and parse JWKS key signing data for a JWT.
- jsonwebtoken: Provides library to encode/decode and validate a JWT token.