Catalog npm
Back to packageRELEASE DETAILS

0.0.1

npm

7tr

Cloudflare page plugin for tRPC

Published6 Oct 2022
Direct dependencies6
Transitive dependenciesNot calculated

README

Current package documentation

tRPC Pages Plugin

This plugin allows developers to create tRPC server on Cloudflare Page Function rapidly.

You can see demo site on https://cloudflare-pages-plugin-trpc.pages.dev.

Warning

This plugin is on tRPC@10.x. It's still in alpha, expect bugs and there're lots of breaking changes.

How to use

If you have any tRPC router, just set it into this plugin!

For example, you have router as like as below:

// router.ts
import * as trpc from "@trpc/server";

export const router = trpc.router().query("hello", {
  input: z.string().nullish(),
  resolve: ({ input }) => {
    return `hello ${input ?? "world"}`;
  },
});
export type AppRouter = typeof appRouter;

You can deploy it to Cloudflare Pages Function right now.

import { router } from "./router.ts";
import tRPCPlugin from 'cloudflare-pages-plugin';

// That's it!
export const onRequest: PagesFunction = tRPCPlugin({ router });

More practical code deployed to the demo site can be found in the /examples folder.

What is tRPC ?

tRPC is library that allows End-to-end typesafe APIs made easy. There are many resource to explain tRPC concept, history and what it try to resolve, but I highly recommend that you try to quick demo first.

Of course, you can see tRPC document on trpc.io.

Why this plugin provide as individual package ?

I've sometimes contributed tRPC, so I also created a pull request that this plugin into tRPC package, and I discussed @KATT who creator of tRPC and @sachinraja who maintainer of tRPC, and result, it's prefer to provide as individual package.

So, I'll continue to actively follow and maintain tRPC updates.

Road map

High

  • Write documents

    • deploy guide
  • Integrate Cloudflare resources

    • R2
    • D1
    • And more...

Middle

  • Testing

    I'm considering how test it.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 6

Native requirements
6 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
@trpc/server
Environment
{
  "local_name": "@trpc/server",
  "alias": false,
  "peer_metadata": null
}
10.0.0-alpha.22runtime
zod
Environment
{
  "local_name": "zod",
  "alias": false,
  "peer_metadata": null
}
^3.19.1runtime
@cloudflare/workers-types
Environment
{
  "local_name": "@cloudflare/workers-types",
  "alias": false,
  "peer_metadata": null
}
^3.16.0development
esbuild
Environment
{
  "local_name": "esbuild",
  "alias": false,
  "peer_metadata": null
}
^0.14.54development
vitest
Environment
{
  "local_name": "vitest",
  "alias": false,
  "peer_metadata": null
}
^0.15.2development
wrangler
Environment
{
  "local_name": "wrangler",
  "alias": false,
  "peer_metadata": null
}
^2.1.10development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-pwhnhasN7zjLJXom/Nxl9U3R/PD2i7+l1KZfprrHeR1DedoC0COfxFUG0ENcYguiHv5Upe5oen6DT8fnotcPuw==",
  "shasum": "cc80e277b88f028eb86a721895bd09ed8bff71b0",
  "tarball": "https://registry.npmjs.org/7tr/-/7tr-0.0.1.tgz",
  "fileCount": 5,
  "unpackedSize": 28177,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIAddGdKTVyaNwGoPIJ3S4484PTTXbAg7pTyfA/SBcztDAiEAwHmmWen8K17gNbGnSoepFurUVL1jcrHvLfPmFqUc+Ac="
    }
  ],
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjPuczACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmreXg/9Fqt7Rn5R067CMPdeyRXGgnaNFCDnitnPnFcS85cA5qP28LK4\r\ncFUhAUGloh7HMZKl5r89sDxVB+EVjeNSeqSOUc2bEJaj2A1RcSSScjqneF1c\r\nPoE1Iti2cJ74rvI9d24SHFZ8LSkJ3vaKXUekz3wwNMEJzMra4B+LbmX5u/Kr\r\nSxlcpE2HypSa46Z65TeEzC+X5R0mGxX1UblZwMeuuyYlw1+lgjMtMRvJCqqt\r\n3HPhlAdtA3RrJjqlIyHYXVyLRfXu/V8cIcfBHQ5biUrRCTt4TNwbs3033QKM\r\nnjk/Jnxa72um8V77LthYz7/m4BDzYiMg2ogJZqT0Aiz7Sea8q6Lf+ZHGyOeX\r\n2nS9FXUML2dffpuP7AtapcDvrFjlhkxj3XWgIuwmLv0+0LdV7vwfx6+5uSNu\r\nl2V4+tKsbxmFvBxsQ6Y2XonUdeIWFcuq3wbdfu5TyIw7P5pW5gTt9dcF46ni\r\nC6eGlLakYUV5bbUnpxP8MHsO76mrhXpRxZT3nRQaoQfjAC4RRZFn9YJ1Gduc\r\nK2D9IFNDJIwCpnXWMF2OxYfpC8X1tKwKLsbr+DTjpyNjxzwnmhbc9UlLlFdH\r\nLeU4Cn+J1Qewg3utH53uarmtO9Gc8Q6/rF+CMLIXCwuGTk7UiiEktgjVrfFA\r\nDEN1xBAyl7cpw0IlRkaSN0ePNfFsggm/y58=\r\n=xpVB\r\n-----END PGP SIGNATURE-----\r\n"
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 21:12 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:e4d4640df0dc6e2462344db34a042b246eb824d04b72ac9211cd036f5c16bc85

Other collected versions

View all collected versions →