Catalog npm
PACKAGE EXPLORERView in registry

7tr

npm

Cloudflare page plugin for tRPC

Versions collected1
Direct dependencies6From release 0.0.1
Last observed20 Oct, 21:12 UTC

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.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.0.1Registry latest6 Oct 20226

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

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:e4dc97240423b9372c1b10a382a537ac29a07a40e0c21dde9b4b82c647841cdd