.env.local
file:
.env.local
file, and you’re good to go.
layout.tsx
file:
events
which Dynamic provides but let’s come back to that and first add the server side code.
getKey
function which is used to fetch the public key which you can use to decode the JWT. This function will make an API call to Dynamic. We’ll add this to the same file:
dynamic-wrapper.ts
file we’ll adjust the settings object passed to DynamicContextProvider as a prop to the following:
getCsrfToken
function which NextAuth provides. This is important because NextAuth uses CSRF tokens to prevent CSRF attacks.
requiresAdditionalAuth
which signifies that the token requires MFA to be completed before the token is considered valid and the user is fully authenticated.
Our SDK handles this for the frontend, but for the backend you will need to check this scope and handle it accordingly.
To do this, you can add a check for the requiresAdditionalAuth
scope in the authorize
function in the auth.ts
file:
null
if you do not want to handle the token with the requiresAdditionalAuth
scope.
useSession
hook.