AccessVerdict

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.

01

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!,
});
02

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.

03

ERROR

Fail closed when verification is unavailable

Treat status:error as a temporary authorization infrastructure condition rather than a normal policy denial.