CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/nextjs-api-patterns

Next.js App Router API patterns — Route Handlers, Server Actions, middleware, validation, caching, error handling

92

1.58x
Quality

90%

Does it follow best practices?

Impact

95%

1.58x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

Evaluation results

98%

39%

Build an Auth-Protected Dashboard API

Criteria
Without context
With context

Middleware with proper matcher

75%

83%

Auth check in middleware returns 401

70%

100%

Params awaited in dynamic routes

0%

100%

Search params for pagination

62%

100%

GET cache control for dynamic data

66%

100%

Validation on POST endpoint

40%

100%

request.json() wrapped in try/catch

100%

100%

Structured error responses

30%

100%

No internal error leaks

100%

100%

Functional implementation

80%

100%

96%

35%

Build a Blog Post Management System

Criteria
Without context
With context

Route Handlers for public API

100%

100%

Server Actions for admin forms

100%

100%

Revalidation after mutations

100%

100%

Validation in both Route Handlers and Server Actions

16%

66%

Server Action error handling pattern

0%

100%

Params awaited in dynamic routes

10%

100%

Structured error responses from Route Handlers

33%

100%

use client on form components

62%

100%

Functional implementation

90%

100%

91%

28%

Build a Contact Form with Server Action

Criteria
Without context
With context

Server Action used (not Route Handler)

100%

100%

Zod validation with safeParse

0%

100%

Field-level errors returned as state

100%

100%

useActionState hook used

100%

100%

Revalidation after mutation

0%

100%

'use client' on form component

100%

100%

Loading/pending state

100%

100%

Error boundary

0%

0%

Functional implementation

70%

90%

100%

53%

Build a Restaurant Menu API

Criteria
Without context
With context

Params awaited in dynamic routes

0%

100%

Zod or schema validation on input

0%

100%

Structured error responses

38%

100%

request.json() wrapped in try/catch

100%

100%

NextResponse.json used correctly

70%

100%

GET caching control

100%

100%

No internal error leaks

37%

100%

Error boundary for menu page

0%

100%

CRUD endpoints functional

100%

100%

91%

18%

Build a Webhook Receiver

Criteria
Without context
With context

Middleware with matcher config

71%

78%

Middleware at project root

100%

100%

Middleware uses only Web APIs

100%

100%

request.json() wrapped in try/catch

100%

100%

Webhook payload validation

58%

100%

Structured error responses

50%

70%

Signature verification

100%

100%

GET events endpoint with cache control

0%

100%

No internal error leaks

62%

62%

Functional implementation

100%

100%

Evaluated
Agent
Claude Code
Model
Claude Sonnet 4.6

Table of Contents