Solid Start Internal Fetch

Is there official or unofficial/hacky support for internal fetch at this point? The docs still mention it being passed to API route handlers but I'm not seeing that being the case (anymore?). Anyone figured out a working even hacky solution, directly calling Nitro internals or anything? (I sent this originally in #solidstart but realized this was probably the proper place for it)
3 Replies
peerreynders
peerreynders6d ago
As far as I can tell If you use - core use server functions and then - wrap those with API routes the need for an internal fetch mostly goes away because server code can use "use server" functions without overhead. Design-wise it's a re-framing from defaulting to API routes and instead focusing on server functions that can support API routes as well for non-SolidStart clients.
Adam Goldstein
Adam GoldsteinOP5d ago
I do get that, and I'm personally a huge fan of server functions, unfortunately I'm stuck at the moment using Auth.js and they seem to pass everything through route handlers. Since internal fetch is something Nitro specifically allows, I'm assuming that behavior is being suppressed somewhere, I'm happy to patch the official library to get that working in an unofficial/unsanctioned manner, I just figured I'd reach out to see if anyone had beat me to it figuring out where I'd need to poke around At the same time, one of my favorite parts of the ethos behind solid start is the idea of isomorphic code, the value of writing code once to produce identical behavior on cilent and server, and avoid skew from duplicated logic. Excluding internal fetch would seem to go directly against that And because Solid Start follows not only web standards but is built on h3 which has a fair number of libraries out there providing compatible route handlers with pre-written functionality (for one example I've used myself, ipx), I think it's reasonable to expect that some users will bring in existing route handling logic from external sources not built for running through "use server", and allowing isomorphic support seems worth it for that case, for my two cents Just something to throw out there
peerreynders
peerreynders4d ago
Because of the Vinxi layer I believe $fetch doesn't work in Dev which means it doesn't really work.
https://discord.com/channels/722131463138705510/910635844119982080/1342244356844814498 The way I'm reading the room is that at this particular point in time “minimizing vinxi” is the top priority for the joint SolidStart/TanStackStart project. By extension fixing internal $fetch (or accepting PR's to the that regard) isn't really a priority until that “minimization effort” has been completed; $fetch being broken right now means it doesn't have to be fixed because nobody can rely on it right now anyway.
Fetch - Nitro
Nitro provides a built-in fetch API that can be used to get data from server endpoints or from other sources. It's built on top of the unjs/ofetch.

Did you find this page helpful?