$state and the onsubmit attribute), which is what new SvelteKit projects create.
1. Save your Public Key
Copy the Public Key from the Endpoint form’s General tab and add it to.env in your project root:
.env
PUBLIC_ to browser code. The key is safe to expose; it can only add responses to this form.
2. Create the page
src/routes/contact/+page.svelte
/contact, send a test response, and check Submissions.
Good to know
- On Svelte 4, replace
$state(...)with plainletvariables and useon:submit={onsubmit}instead of{onsubmit}. - This is a client-side request, so you do not need a
+server.tsendpoint or a form action. - Restart
vite devafter editing.env. - If you enable domain restriction, allow
localhostwhile you develop.