Basic Actions in Svelte

From the SvelteKit cheat sheet ยท Form Actions ยท verified Jul 2026

Basic Actions

Server-side form handling

javascript
// +page.server.js
export const actions = {
  default: async ({ request }) => {
    const data = await request.formData();
    const email = data.get('email');
    
    // Process form
    return { success: true };
  }
};

// +page.svelte
<form method="POST">
  <input name="email" type="email" />
  <button>Submit</button>
</form>
๐Ÿ“ Progressive enhancement - works without JavaScript
๐Ÿ”’ Server-side validation and processing
๐Ÿช Direct cookie access for authentication
โšก use:enhance for optimistic UI updates

More Svelte tasks

Back to the full SvelteKit cheat sheet