Rami
Rami5mo ago

Can I create custom terminating links?

There are cases where a user of my application is offline and can't have access to the server. I'd like to call certain functions that would properly handle that case. My best guess would be inside the Links. In that case can I create a terminating Link that would make that request return early without invoking the server? On a high level, what I'm trying to do is a local-first/offline-first application with tRPC
4 Replies
Rami
Rami5mo ago
@BeBoRE Sorry for the ping but I'd really appreciate your opinion on this
BeBoRE
BeBoRE5mo ago
You can use persistQueryClient to cache requests made by tRPC
persistQueryClient | TanStack Query Docs
This is set of utilities for interacting with "persisters" which save your queryClient for later use. Different persisters can be used to store your client and cache to many different storage layers. Build Persisters
Rami
Rami5mo ago
It works but I can't really rely on it when there's a large amounts of data to cache. I also wanna be able to make insertions in offline mode. Think a to-do list app on your phone. So I was thinking I could have an sqlite DB stored locally. So my question is, how can I run these client-side DB operations with tRPC? Links seemed like a possible option, but also this https://discord.com/channels/867764511159091230/1221200250879082647 can also be an option if it's possible... Is it?
BeBoRE
BeBoRE5mo ago
tRPC is a tool used to achieve better end-to-end typesafety (often) between client and server. tRPC provides no utility if it's not used in a similar use-case. Your use-case requires storing and retrieving data from a data-store without crossing the boundary between client and server. If your concern is with typesafety within this context, tRPC cannot solve this issue. If you want to have typesafety when storing and retrieving data from a database you can use Drizzle or Prisma. If you need an async state manager you can use TanStack Query. You can use createCaller to invoke a procedure when you have access to the router directly.
Server Side Calls | tRPC
You may need to call your procedure(s) directly from the same server they're hosted in, createCallerFactory() can be used to achieve this. This is useful for server-side calls and for integration testing of your tRPC procedures.
More Posts
I want to use tRPC but I don't want a serverCan I have tRPC exclusively run on the client? I don't want to have any servers. The architecture a“Integrating Drizzle Prepared Statements with tRPC Context”I’m currently using tRPC and Drizzle for my project. In tRPC, we generally place the database driverI have an actual data returned, but I get 404 spammed in the consoleIt's a bit weird, I have the data returned but I also get 404 at the same time. Here is usage on thNo "query"-procedure on path "auth.getProfile"I am getting bunch of these errors and I can't figure this one out yet. I saw bunch of issues createType '[]' has no properties in common with type 'MutateOptions<{ id: string....Is it possible to get this to work? i am trying to make a single action that works across 2 routers.Strange error when testing with Auth.js v5Hi there, I just created a fresh Next.js project and added `next-auth` version 5 beta for authentictRPC failed on beehiiv.fetchBeehiivPosts: Invalid state: Controller is already closedIs there any solution to this error. I am getting while I try to hard refresh a page where I am callIs there a way to configure a trpc router to require an output() schema to be specified?I would like to require the output() schema to be specified on all the queries and mutations in my pErrors not caught in proceduresI have an application that uses Solid Start `@solidjs/start`. Most Solid Start apps use the `fetchResilent failure on client query?Hey friends, long time listener, first time caller 😉 I have encountered a quite confusing quirk tha