Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expanded support for Svelte 5 #10761

Closed
benmccann opened this issue Sep 20, 2023 · 8 comments · Fixed by #13140
Closed

Expanded support for Svelte 5 #10761

benmccann opened this issue Sep 20, 2023 · 8 comments · Fixed by #13140
Assignees
Labels
Milestone

Comments

@benmccann
Copy link
Member

benmccann commented Sep 20, 2023

Describe the problem

Add support for Svelte 5 and runes: https://svelte.dev/blog/runes

Describe the proposed solution

At some point it'd be nice to have rune versions of the built-in stores

Maybe the types generation stuff could use some changes? @dummdidumm would know better about that...

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

@benmccann benmccann added this to the 2.0 milestone Sep 20, 2023
@benmccann benmccann changed the title Support Svelte 5 Expanded support for Svelte 5 Nov 30, 2023
@benmccann benmccann modified the milestones: 2.0, soon, 3.0 Dec 3, 2023
@ThorFjelldalen
Copy link

I tried creating a +layout.svelte.ts file, for initializing a class with $state properties in the load function of the +layout, but this generates an error:

image

I got around it by doing it in the +layout.svelte file instead. Is this something that will be possible in the future?

@enyo
Copy link
Contributor

enyo commented Jun 5, 2024

@ThorFjelldalen since everything in the load function will need to be serialized if it runs on the server, I don't think that it makes a lot of sense to create $state in that function.

@ThorFjelldalen
Copy link

@enyo Thank you for answering! Ah, I currently use CSR, and am not used to thinking in terms of SSR.

But would this be any different to if we were to use the writable() stores, as we do in Svelte 4? The question concerns both this specific use case, but also the general use case of $runes in sveltekit ts-files. I'd think that it may be a valid use case at least in a CSR context?

Would you happen to know if there is any documentation of best practices when using stores in a SvelteKit-app? I have a global store that is initialized by api requests, and thought that the +layout / +page load function was the natural location for this, as it is relevant to the entire application.

@madeleineostoja
Copy link

is there a rough roadmap for making runes versions of the built-in stores? Would love to give all my stores the 🔪 when I migrate to runes but the built-in ones make reasoning about a proper refactor harder

@eltigerchino
Copy link
Member

eltigerchino commented Aug 15, 2024

is there a rough roadmap for making runes versions of the built-in stores? Would love to give all my stores the 🔪 when I migrate to runes but the built-in ones make reasoning about a proper refactor harder

There is no roadmap and I don't think any planning will start until a while after Svelte 5 has released.

@dominikg
Copy link
Member

there is a fromStore helper https://svelte-5-preview.vercel.app/docs/imports#svelte-store-fromstore and you can also use $derived to dig into stores let bar = $derived($someStore.foo.bar)
The most used thing is probably page data and thats available through $props, so even without sveltekit native state replacements for stores your svelte5 runes app won't have to interact with stores a lot if you don't want to

@madeleineostoja
Copy link

I wasn’t aware of the new fromStore helper, looks perfect for my use cases, thanks!

The most used thing is probably page data and thats available through $props

Could you elaborate on this one? Other than the route tied to a load function, which always had data on a prop, I didn’t think page data was available through $props anywhere else? Because that is my most used app store, but for the use-case of global data available anywhere down the tree (in components, child routes, etc)

@dominikg
Copy link
Member

you are right, page data in $props is only available on the route itself. From my experience you can get pretty far with that, only reaching for the page store in situations where the prop isn't available (eg parent layout setting title with svelte:head to a value provided by child load)
But it is also totally fine to keep using stores in svelte5. Initial support for a page state in sveltekit might land in 2.x (no promises), full advantage of svelte5 (and vite6) is going to require a new major, which is a bit further out still

@eltigerchino eltigerchino modified the milestones: 3.0, soon Oct 29, 2024
@Rich-Harris Rich-Harris self-assigned this Nov 21, 2024
@dummdidumm dummdidumm assigned dummdidumm and unassigned Rich-Harris Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants