Grifn
Grifn
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Grifn on 10/25/2023 in #questions
Next server actions and REST API
Are server actions going to make REST APIs or tools like tRPC for Next client to server redundant? Or will they still have their place? We are starting a new project and we’re looking at using ts-rest so we can share schemas and validation from client-server-other APIs.
2 replies
TtRPC
Created by Grifn on 7/17/2023 in #❓-help
Next.js app router catch-all HTTP methods
The app router already supports the catch-all file for route resolution, but AFAIK still expects separately method exports like export function GET(). I think this means we can't provide the tRPC NextApiHandler from the app router and we still need to use the pages directory (not a big deal but adding a whole extra directory just for the tRPC route currently). Any way to provide the tRPC Next handler from the app router?
4 replies
TTCTheo's Typesafe Cult
Created by Grifn on 7/12/2023 in #questions
tRPC, SSR, RSC/app directory
Is it possible to use tRPC when rendering a component on the server to get an initial value for a request before refetching on the client on mount? If not, what is the next best thing? fetch on the server and pass value to the client component using tRPC to set the initialValue on useQuery? Are there problems with that? Does anyone have a current workflow in which they are successfully using tRPC with the app directory and able to SSR with data from tRPC useQuery? Is there an alternative solution to using react-query or swr with fetch?
12 replies
TtRPC
Created by Grifn on 7/10/2023 in #❓-help
tRPC + App directory + SSR - current state?
What is the current state of the technologies working together with or without SSR? It looks like some work is/was being done around using tRPC with the new app directory but its hard to tell if that work is completed or what is currently supported or recommended. Can I start a new Next.js project with the new app directory and tRPC and expect to be able to utilize SSR for the RSC (React Server Components)? What problems currently exist? If tRPC requests can't be handled during SSR at this point, can the RSC still render on the server but the tRPC query begin on the client on mount? What is the current best way to use tRPC with the new app directory that best utilizes all of the new RSC features?
11 replies
TTCTheo's Typesafe Cult
Created by Grifn on 12/9/2022 in #questions
Testing with Typescript
When writing tests for a Typescript project, should functions still be written with fail conditions in mind so they can be tested properly? Or are those tests pointless because the project is using TS? Example: Testing a getFirstDayOfWeek function takes a Date as an argument. Of course if a string is provided, the function will fail when it tries to getDay() on the string. Should I check if the date is an instanceof Date and return undefined if not? This can then be tested by providing something other than a Date. I don't know how other developers on the (large) team will interact with the code I'm writing and thinking I should add the fail condition code, but it means a lot of the other code that uses this getFirstDayOfWeek function needs to suffer by expecting either a Date or undefined as a result of the function. Or in this specific case, if a Date isn't provided should I just use today's date and always return a Date.
2 replies