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

page data store now runes state #47

Open
shiftlabs1 opened this issue Dec 21, 2024 · 5 comments
Open

page data store now runes state #47

shiftlabs1 opened this issue Dec 21, 2024 · 5 comments

Comments

@shiftlabs1
Copy link

The stores expected in sveltekit-flash-message as parameters are writable stores and page store is now a runes store. this will need updating.

@hgoona
Copy link

hgoona commented Dec 31, 2024

The stores expected in sveltekit-flash-message as parameters are writable stores and page store is now a runes store. this will need updating.

is there a way to get past this?

@alexweber
Copy link

alexweber commented Dec 31, 2024

@hgoona It actually still works, you just gotta import the old page store and ignore the deprecation warnings:

<script lang="ts">
// Using both the new page from app state for other things and old one for flash messages.
import { page } from '$app/state';
import { page as pageStore } from '$app/stores';

const flash = getFlash(pageStore);
</script>

{#if $flash}
   <div>{$flash.message}</div>
{/if}

Caveat: if you are setting flash messages on the server before a redirect you will get taken to an error page for a split second before the redirect kicks in. I assume this is due to the Svelte 4 to 5 migration.

It's a little annoying but I'm ok with it for now...

@ciscoheat
Copy link
Owner

If there's a way to detect which one of the stores are used at runtime, I could add a compatibility fix.

@ciscoheat
Copy link
Owner

With 2.4.5 it should now be possible to use $app/state as well as the old $app/stores, check it out and see if it works.

@bagaskarawg
Copy link

@ciscoheat Working great with Svelte 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants