@@ -137,6 +137,10 @@ npm install trpc-docs-generator
137137
138138- ` @trpc/server ` ^11.0.0
139139- Zod v4+ (with ` toJSONSchema ` support)
140+ - Node.js 16+ (with native ESM support)
141+
142+ ** Note:** This package uses native ESM with explicit ` .js ` file extensions in imports, ensuring
143+ compatibility with Node.js native module resolution (Node 16+, Node 22+).
140144
141145<br />
142146
@@ -407,6 +411,10 @@ Generates a complete HTML documentation page from route information.
407411- ` routes ` - Array of route information from ` collectRoutes() `
408412- ` options ` - Optional configuration:
409413 - ` title ` - Page title (default: ` 'API Documentation' ` )
414+ - ` transformer ` - Data transformer used by tRPC router (optional)
415+ - Set to ` 'superjson' ` if your router uses the superjson transformer
416+ - This ensures the test playground correctly wraps requests/responses in ` {json: ...} ` format
417+ - See [ SuperJSON Support] ( #superjson-support ) for details
410418
411419** Returns:**
412420
@@ -438,6 +446,67 @@ type RouteMeta = {
438446
439447<br />
440448
449+ ## SuperJSON Support
450+
451+ If your tRPC router uses the [ superjson transformer] ( https://trpc.io/docs/data-transformers ) , you
452+ need to configure the docs generator to match. SuperJSON wraps requests/responses in a special
453+ format (` {json: ...} ` ) to support JavaScript types that standard JSON doesn't handle (Date,
454+ undefined, BigInt, Map, Set, etc.).
455+
456+ ### Usage with SuperJSON
457+
458+ ``` typescript
459+ import { initTRPC } from ' @trpc/server' ;
460+ import superjson from ' superjson' ;
461+ import { collectRoutes , generateDocsHtml } from ' trpc-docs-generator' ;
462+
463+ // Your tRPC router with superjson transformer
464+ const t = initTRPC .create ({
465+ transformer: superjson // Using superjson
466+ });
467+
468+ const appRouter = t .router ({
469+ getEvent: t .procedure .input (z .object ({ id: z .string () })).query (() => ({
470+ id: ' 123' ,
471+ name: ' Conference' ,
472+ startDate: new Date () // Date objects work with superjson!
473+ }))
474+ });
475+
476+ // Generate docs WITH superjson support
477+ const routes = collectRoutes (appRouter );
478+ const html = generateDocsHtml (routes , {
479+ title: ' My API Documentation' ,
480+ transformer: ' superjson' // Enable superjson in test playground
481+ });
482+ ```
483+
484+ ### What This Does
485+
486+ ** Without** ` transformer: 'superjson' ` :
487+
488+ - Request: ` {"id": "123"} `
489+ - Your superjson-enabled tRPC server expects: ` {"json": {"id": "123"}} `
490+ - Result: ❌ ** Request fails** with "Invalid input: expected object, received undefined"
491+
492+ ** With** ` transformer: 'superjson' ` :
493+
494+ - Request: ` {"json": {"id": "123"}} `
495+ - Response unwrapping: Automatically extracts data from ` {result: {data: {json: {...}}}} `
496+ - Result: ✅ ** Everything works perfectly**
497+
498+ ### When to Use
499+
500+ Enable ` transformer: 'superjson' ` if your tRPC router:
501+
502+ - Uses ` superjson ` transformer in ` initTRPC.create({ transformer: superjson }) `
503+ - Returns Date objects, undefined values, BigInt, Map, Set, or other non-JSON types
504+ - Is configured with any custom transformer that wraps data
505+
506+ If you're using standard JSON (no transformer), you don't need this option.
507+
508+ <br />
509+
441510## Examples
442511
443512### Full Featured Router
0 commit comments