Replies: 3 comments
-
Thanks for sharing your experience! We'll consider all this, but in the meantime I wanted to just leave you with one note for a small portion of this that has been addressed.
|
Beta Was this translation helpful? Give feedback.
-
I'll say this: I don't know if every As I wrote, some things I seem to understand better than I did the first time I read the documentation, but it wasn't at all easy to understand all those links |
Beta Was this translation helpful? Give feedback.
-
Related - #6211 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have been using SvelteKit for a bit now and I am still having trouble getting used to
invalidate
+ specialfetch
.I come from NextJS and am used to using SWR cache libs like
react-query
anduseSWR
as an abstraction layer on top of raw "fetch" layer to interface with API data. I am used to thinking in terms of "domain" objects (that could be fetched from linking various Rest APIs, GraphQL endpoints, from local storage, or mocked API response, etc. whatever the detail, doesnt matter). This greatly simplifies the application logic as it allows me to never think about how something is grabbed under the hood.It allows me to think about & interact with domain objects in unique cache keys like
posts
orpostById.123
orcurrentUser
. The interactions could be: accessing, refetching (or "invalidating"), polling. And I love that all of this could be done agnostically across SSR/CSR thanks to seemless hydration + simple access API likeconst { data, loading, error } = usePost({ id: 123 })
andqueryClient.invalidate("post.123")
.I've felt that SvelteKit is quite limiting/confusing to implement the access pattern like above for the following reasons (granted, some of these are going away with the next major update):
session
vsstuff
vssvelte store
isn't really clearly documented.load
function is hybrid rendered (SSR + CSR) - lifecycle is unclear, i.e. when which code gets run.hooks => layout => layout override => page => etc.
.fetch
. => don't know how the "dependencies" list actually gets built, and what things exist in dependencies.fetch
+invalidate
is the documented approach to share data from SSR => CSR, but it forces you to only think aboutfetch
+ Route URL as the method of getting data (even tho the data could be fetched from other locations like cookie, graphql client, local storage, etc.).invalidate
method can handle both API routes that have beenfetch
-ed using the magicalfetch
, or the whole page itself?At the end of the day, I want an easy way to abstract and unify how a "data" is accessed within the application code no matter SSR/CSR context.
I feel that it's been very easy to write brittle code as i have yet to find an idiomatic way to abstract all this.
I know lots of changes are coming (especially regarding storage methods like session/stuff), but I would love to hear everyone's thoughts on this topic in general.
Beta Was this translation helpful? Give feedback.
All reactions