NEXT.JS GUIDE
Server-side token gating in Next.js.
Keep wallet authorization in a Route Handler or other trusted server boundary, not in client-only UI logic.
SETUP
Create one server-only AccessVerdict client
Put the project key in a server environment variable and create a reusable client module.
import "server-only";
import { createAccessVerdictClient } from "@accessverdict/sdk";
export const accessVerdict = createAccessVerdictClient({
apiKey: process.env.ACCESSVERDICT_API_KEY!,
});ROUTE
Verify before returning the protected resource
Call the saved policy from the Route Handler that controls the resource and reject denied decisions before returning data.
ERROR
Fail closed when verification is unavailable
Treat status:error as a temporary authorization infrastructure condition rather than a normal policy denial.