T
tRPC

❓-help

tRPC and vite serverless, are there any exmaples?

ZZion12/29/2023
Now that tanstack router is out I would want to move out of nextjs, but keep the convenience of hosting on vercel with serverless. I saw that theres some vite-vercel plugin (vite-plugin-vercel) for SSG/ISR/serverless functions, but not sure how I would integrate it with tRPC. are there any exmaples for something like that?
AEAhmed Elsakaan12/29/2023
vite by default isn't a full stack type of tool, so it can't be compared with nextjs fully. What I would recommend if you're going with that route is to just have tRPC as it's own server using the standalone adapter and seeing if that works for you, you can use other adapters like fastify for example if you need something more than that.
ZZion12/29/2023
Yeah, I made a template with fastify and vite, it works well, but I'd like to have a solution I can host on vercel, and have ssr/ssg. the vite-vercel plugin seems good, but Im not sure theres a adapter for it
AEAhmed Elsakaan12/29/2023
if it uses normal request/response you can hook up the trpc fetch adapter to it @julius 😜
AEAhmed Elsakaan12/29/2023
Fetch / Edge Runtimes Adapter | tRPC
You can create a tRPC server within any edge runtime that follow the WinterCG, specifically the Minimum Common Web Platform API specification.
Jjulius12/29/2023
really depends on what server framework you end up going for
AEAhmed Elsakaan12/29/2023
apparently vite has a vercel plugin that allows you to do api endpoints like next.js
Jjulius12/29/2023
i looked into vinxi+nitro (same as SolidStart went for) and looks quite proimising to build something nice with
ZZion12/29/2023
I see that vinxi have their own router tho? (unless I didnt get the docs right), I really want a stack with tanstack router, a stack of vite-trpc-tanstack router with othert features from nextjs (ssr/ssg/isr and serverless - if possible) would be really powerful and full typesafety. seems like the vite vercel plugin takes care of it, no idea how to use trpc with it tho
Jjulius12/29/2023
https://github.com/nksaraf/vinxi/tree/main/examples/react/ssr/tanstack-router-app you can also just take tanners example and add a trpc route to the express router https://github.com/TanStack/router/blob/main/examples/react/basic-ssr-streaming-file-based/server.js https://trpc.io/docs/server/adapters/express trpc is really flexible in how to "host" it so i think that would be the least of your problems πŸ™‚
ZZion12/29/2023
ok thats cool, I assume vinxi isnt really production ready yet tho, from the version numbering. I dont really mind having a stateful server like express/fastify, but where would I host it? the docs for it seems empty (in vinxi)
Jjulius12/29/2023
you can deploy it serverless to vercel no problems https://vercel.com/guides/using-express-with-vercel#standalone-express
How to Deploy an Express.js Application to Vercel
Learn how to deploy an Express.js application to Vercel using Serverless Functions.
Jjulius12/29/2023
doesn't have to be stateful
ZZion12/29/2023
neat, I tried deploying serverless fastify in a monorepo and had lots of problems with making it run in dev or production, hope I wont have the same issues. does it matter if I use express or fastify? (as in, performance or whatever)
Jjulius12/29/2023
i think fastify is more performant but express has a larger ecosystem
ZZion12/29/2023
hm, would the ecosystem really play a part if I just use trpc and its serverless? dont really know much about backend stuff

Looking for more? Join the community!

T
tRPC

❓-help

Join Server
Recommended Posts
How can i use inferprocedureoutput?I'd like to write this code type-safely:```ts const handleQuery = (query: /* ? */) => {} const MyCoCan a URL be formatted with dashes, such as "user-list" in the context of trpc?Can a URL be formatted with dashes, such as "user-list" in the context of trpc? ``` const appRouter Incorrect type inference with discriminated unions.Hey folks, I am having a really weird issue. Here is a minimal reproducible example: **https://tsplGet Query Key on ServerI'm following some recommended practices from one of the react query maintainers `@tkdodo` and want ReferenceError: Cannot access 'appRouter' before initializationHi friends im having trouble implementing a "protected" or "private" procedure in TRPC using Next.jstrpc openapi does not work on app routerhttps://github.com/jlalmes/trpc-openapi Can i just know if trpc open api for next is also applicableSubscription types are not inferred while queries and mutations are working fineI am NOT working with a monorepo but while query and mutation types are being inferred out of the boHow are thrown (unhandled) exceptions safe to pass?Hi, I started looking into error handling more and understand that all errors get wrapped in a TRPCECanary useUtils and createTRPCQueryUtils type not callableTrying to access utils object in my application after using `useUtils` or `createTRPCQueryUtils` andtRPC run express under the hood?tRPC run `expressjs` under the hood?Modify mutation error messages?We occasionally get timeouts from cloudfront which gives the user an error about how the cloudfront server-side helpers doesnt work with `Hydrate` and `QueryClient`environtment: node v20.9.0, npm Hi i tried to implement server-side helpers but somehow it just doesUnable to mock unstable_batchStreamLink network responseHi there! I have a couple API endpoints that call third party dependencies and would like to mock a Using trpc with fastify server and nextjs clientHello, is it possible to use fastify for server and have a nextjs client and make use of the SSG / SI can't mutate or query in SvelteKitEnvironment: Node 20 with Yarn I'm not getting any specific errors but I don't get the "mutate" or "TRPCError class, public readonly cause?: Error; this line should have override functionhey i am trying to use the TRPCError for throwing errors in my apps, but i am getting this error, chWhy do people use SplitLink? (http + websocket)Why not just use websockets for everything? Just curious.Force user to loginHow can I redirect the user to "/login" if the user are not logged in?TRPC with middly middleware on lambdaHello, has anyone used middly middleware on AWS lambda? Thanks!tRPC on Vercel Serverless without Next?I would love to be able to use tRPC in a vercel serverless context, but not in a Next app – just the