I'm trying out sveltekit form actions, and it keeps on giving 500 Internal Error with the title in the console: node.component is not a function
src/routes/login/+page.server.js
import type { Actions } from '@sveltejs/kit';
export const actions: Actions = {
default: async ({ request, cookies, url }) => {
return { success: true }
}
};
src/routes/+page.svelte
<form method="POST" action="/login">
<div class="card-body">
<button class="btn btn-primary w-100" type="submit">Login</button>
</div>
</form>
You need to add a file src/routes/login/+page.svelte since without it the form won't be able to work. Do note that it needs to be that exact filename (+page.svelte or +layout.svelte respectively).
Or, if you have a +layout.server.ts, add an +layout.svelte with <slot/> in it
I'm adding this answer because I ran into this same problem, but couldn't find a missing +page.svelte for a form.
I had a nested +layout.server.ts that I was just using to serve data, but I didn't have a corresponding +layout.svelte.
I just put <slot /> in this new, nested +layout.svelte.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With