Madaxen86
Solid Start offline indicator in mobile / desktop app
You can add it to app.tsx or create a layout at the root of the routes directory (assuming you are using file routes)
https://docs.solidjs.com/solid-start/building-your-application/routing#nested-layouts
2 replies
How to include Gzip compression to Solid Start project?
Depending on where you deploy the app, the server might handle compression as well.
E.g. I have a solid-start-app running on a vps with an nginx server which compresses all responses automatically:
20 replies
[h3] [unhandled] H3Error: Client-only API called on the server side. Run client-only code in onMount
You must not export functions wrapped with query from a file with toplevel "use server"
Only the function inside query can be a "use server" function.
The reason is that the queried function needs to run on the client.
The wrapped function will then be a RPC call.
23 replies
Help: Preflight OPTIONS Requests In SolidStart. I'm Lost!
I found this:
https://answers.netlify.com/t/cors-and-netlify-api-requests-not-working-on-deployment/48538/4
and this is probably better
https://answers.netlify.com/t/handling-cors-preflight-requests/42724/5
18 replies
Confusion about `"use server"`
Query is actually just there to dedupe request through a client side in memory cache.
Actions are there to update data in the client and update the cache through the actions response in a single fight ("single flight mutations") but they assure that functions run on the server.
So they are not making the functions to RPCs.
Without "use server" they‘ll run on the server only during the initial load, once hydrated in the browser they run on the client.
Only if you use "use server" they always they’ll be replaced with an RPC call once the app has hydrated in the browser.
I‘ve made a video showcasing this by returning the current time.
https://youtu.be/Qw9am5NL6AI?si=eDgwbULcLqewNm8-
6 replies
How to Implement Page Caching
I am not aware of a feature/component like that.
That’s why I recommended to either using tanstack query which caches the fetched data. They pages have to rendered again client-side but there’s no request to the server for already visited pages until you trigger to refetch the data.
4 replies
I get ERR_UNHANDLED_REJECTION
Got it.
You can not export actions and query from files with top level "use server", because they need to run on the client.
Move them to another file or place the "use server" directive at the top of the async functions.
8 replies
Handling 404 within existing catch-all route
Wrap the page also in a Suspense as data will be undefined until it has resolved. Otherwise you'll be showing your NotFound while fetching.
Alternatively. You can check in getPageData if the response has data and throw if not. Keeps your page cleaner.
5 replies
I get ERR_UNHANDLED_REJECTION
Can't reproduce it.
Maybe you can in a stackblitz?
https://stackblitz.com/edit/github-52ahab?file=src%2Froutes%2Findex.tsx,src%2Fserver.ts
What's your router version?
Unrelated: You'll probaly need to "use server" to the function to be able to get and update the session.
8 replies
Problems to acess objects inside an array
Have a look at this guide.
With
produce
you‘ll simplify your code.
https://docs.solidjs.com/guides/complex-state-management#adding-to-an-array6 replies
Handling <input>
Well not a controlled by React’s definition.
Because in Solid all elements are real HTML elements they will fallback to their native behavior. For an input value is then just the defaultValue in Reacts sense.
But you can control what's displayed on the input e.g. make all characters lowercase. That's controlled for me...
6 replies