What are SvelteKit form actions?

Answer

Form actions in SvelteKit are server-side functions that handle HTML form submissions. Defined in +page.server.js: export const actions = { default: async ({ request, cookies }) => { const data = await request.formData(); const email = data.get('email'); await createUser(email); redirect(303, '/dashboard'); }, login: async ({ request }) => { ... }, logout: async ({ cookies }) => { cookies.delete('session'); } };. In the page, use HTML forms: <form method="POST"><input name="email"><button>Submit</button></form>. For named actions: <form method="POST" action="?/login">. Use the enhance action for progressive enhancement — works without JavaScript (pure HTML form) and enhances with client-side JavaScript when available. Return validation errors: return fail(400, { errors: { email: 'Invalid' } }). Form actions are SvelteKit's server-first approach to mutations.