Skip to content
Back to skills

Orpc Superjson

ASecurity

Replace the default oRPC RPC serializer with SuperJson.

  • 8 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 12, 2026
businessgit

Works with

  • cli

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add ali-master/skills --skill orpc-superjson --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Orpc Superjson?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Orpc Superjson
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ali-master-orpc-superjson/badge)](https://www.skillsdirectory.com/skills/ali-master-orpc-superjson)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: oRPC SuperJson
description: Replace the default oRPC RPC serializer with SuperJson.
license: MIT
metadata:
  author: Ali Torki
  homepage: https://github.com/ali-master
  version: "1.0.0"
---

# SuperJson

Replace the default oRPC RPC serializer with [SuperJson](https://github.com/blitz-js/superjson).

> Default oRPC serializer is faster and more efficient, but SuperJson is widely adopted.

## SuperJson Serializer

> Only supports SuperJson-compatible data types plus `AsyncIteratorObject` at root for Event Iterator. Not all [RPC supported types](/docs/rpc-handler#supported-data-types) work.

```ts
import { createORPCErrorFromJson, ErrorEvent, isORPCErrorJson, mapEventIterator, toORPCError } from '@orpc/client'
import type { StandardRPCSerializer } from '@orpc/client/standard'
import { isAsyncIteratorObject } from '@orpc/shared'
import SuperJSON from 'superjson'

export class SuperJSONSerializer implements Pick<StandardRPCSerializer, keyof StandardRPCSerializer> {
  serialize(data: unknown): object {
    if (isAsyncIteratorObject(data)) {
      return mapEventIterator(data, {
        value: async (value) => SuperJSON.serialize(value),
        error: async (e) => new ErrorEvent({
          data: SuperJSON.serialize(toORPCError(e).toJSON()),
          cause: e,
        }),
      })
    }
    return SuperJSON.serialize(data)
  }

  deserialize(data: any): unknown {
    if (isAsyncIteratorObject(data)) {
      return mapEventIterator(data, {
        value: async value => SuperJSON.deserialize(value),
        error: async (e) => {
          if (!(e instanceof ErrorEvent)) return e
          const deserialized = SuperJSON.deserialize(e.data as any)
          if (isORPCErrorJson(deserialized)) {
            return createORPCErrorFromJson(deserialized, { cause: e })
          }
          return new ErrorEvent({ data: deserialized, cause: e })
        },
      })
    }
    return SuperJSON.deserialize(data)
  }
}
```

## SuperJson Handler

```ts
import { FetchHandler } from '@orpc/server/fetch'
import { StrictGetMethodPlugin } from '@orpc/server/plugins'
import { StandardHandler, StandardRPCCodec, StandardRPCMatcher } from '@orpc/server/standard'

export class SuperJSONHandler<T extends Context> extends FetchHandler<T> {
  constructor(router, options = {}) {
    options.plugins ??= []
    if (options.strictGetMethodPluginEnabled ?? true) {
      options.plugins.push(new StrictGetMethodPlugin())
    }

    const serializer = new SuperJSONSerializer()
    const matcher = new StandardRPCMatcher()
    const codec = new StandardRPCCodec(serializer as any)

    super(new StandardHandler(router, matcher, codec, options), options)
  }
}
```

## SuperJson Link

```ts
import { StandardLink, StandardRPCLinkCodec } from '@orpc/client/standard'
import { LinkFetchClient } from '@orpc/client/fetch'

export class SuperJSONLink<T extends ClientContext> extends StandardLink<T> {
  constructor(options) {
    const linkClient = new LinkFetchClient(options)
    const serializer = new SuperJSONSerializer()
    const linkCodec = new StandardRPCLinkCodec(serializer as any, options)

    super(linkCodec, linkClient, options)
  }
}
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.