next-13 icon indicating copy to clipboard operation
next-13 copied to clipboard

How to align the client/server DX?

Open KATT opened this issue 3 years ago • 4 comments

Currently, we use rsc.* to fetch data on the server and trpc.* on the client.

I wish this was the same object used so you didn't have to care if you're on the server or the client.

KATT avatar Oct 28 '22 10:10 KATT

fwiw, this is the best dx in my eyes. with this, we have the clear separation of where the data actually comes from. so there is no issue in whether we are fetching client-side or server-side.

imo...

iduuck avatar Oct 28 '22 11:10 iduuck

This isn't possible because with the react-server export condition because you have to pass appRouter for rsc. We can't/don't want to import that on the client. So I think we'd have to go for transpiling if we wanted to do this.

sachinraja avatar Oct 30 '22 14:10 sachinraja

Would something like this help if there was some logic that didn't resolve the router unless it was needed?

createTrpcThingy({
  router: () => import('~/path/to/router'),
  ...otherOptions,
})

or would it affect client bundles?

mmkal avatar Oct 30 '22 15:10 mmkal

ohh yes I think that would help @mmkal! Great idea, I'll try it.

sachinraja avatar Oct 30 '22 16:10 sachinraja