Skip to content
Discussion options

You must be logged in to vote

We can prevent invalidateAll when using the use:enhance action on the form.
First, we pass a custom callback, and avoid calling applyAction when result.type is a redirect.

  <form method="POST" use:enhance={() => {
    return async ({ result }) => {
      if (result.type === 'redirect') {
        // redirect without invalidating
        await goto(result.location);
      } else {
        await applyAction(result);
      }
    }
  }}>

https://stackblitz.com/edit/sveltejs-kit-template-default-fbiwbs?file=src%2Froutes%2Ffirst%2F%2Bpage.svelte,src%2Froutes%2Ffirst%2F%2Bpage.server.ts

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@stefandevo
Comment options

@stefandevo
Comment options

@eltigerchino
Comment options

@NormandoHall
Comment options

@eltigerchino
Comment options

Answer selected by stefandevo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants