How to use $page.form
in components
#7016
-
I see that in |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hi Pasquale, I've made a stackblitz example for you here: Return a value from the action via export const actions = {
default: () => {
console.log('form action running');
return { success: true };
}
}; Receive the value from <script>
import { page } from '$app/stores';
</script>
<h2>The form value</h2>
<p>{JSON.stringify($page.form)}</p> |
Beta Was this translation helpful? Give feedback.
-
Quick follow-up: Is there any way to get type safety when using |
Beta Was this translation helpful? Give feedback.
Hi Pasquale,
I've made a stackblitz example for you here:
https://stackblitz.com/edit/sveltejs-kit-template-default-sfyuzf?file=src/routes/Something.svelte
Return a value from the action via
return
, orreturn invalid(400, {})
+page.server.js
Receive the value from
$page.form
Component.svelte