ciscoheat / sveltekit-flash-message

Send temporary data after redirect, usually from endpoints. Works with both SSR and client.
https://www.npmjs.com/package/sveltekit-flash-message
MIT License
263 stars 6 forks source link

Flash message not appearing when using layout groups. #23

Closed ezynda3 closed 1 year ago

ezynda3 commented 1 year ago

My setup:

// src/routes/(auth)/+layout.server.ts
export { load } from 'sveltekit-flash-message/server'

In my form action I call redirect with a message

// src/routes/(auth)/register/+page.server.ts
export const actions: Actions = {
  default: async (event) => {
    // ...
   const message = {
      type: 'success',
      message:
        'Please check your email and click the verification link to complete registraion. If you do not see an email, please check the spam folder.'
    } as const
    throw redirect('/login', message, event)
  }
}

In the login page $flash is undefined

// src/routes/(auth)/login/+page.svelte
<script lang="ts">
  import { getFlash } from 'sveltekit-flash-message'
  import { page } from '$app/stores'

  const flash = getFlash(page)
  console.log($flash) // undefined
</script>
ciscoheat commented 1 year ago

Hi, the test suite for the library also uses layout groups, but they work fine. I even tried to use the load export as in your example, but no problem. Can you try to reproduce it in a fresh sveltekit app, with the latest version of the library?

ciscoheat commented 1 year ago

Hi, is this still an issue? Closing it otherwise.