SvelteKit Remote Functions Workaround Helpers
dev.to·20h·
Discuss: DEV
🏔️Alpine.js
Preview
Report Post

If you’re like me, you’ve been waiting for Remote Functions in SvelteKit for a long... long time... and they are awesome!

It will be extremely hard to ever go back. Even though they are still experimental, the time they save is priceless.

However, not every feature is ready. So, I am posting a list of them, and their workarounds, and their status.

1. Submit Type

This is the least important, but needed. You may want to declare your enhance function outside the component template.

In form actions, you use types like this:

import type { SubmitFunction } from '@sveltejs/kit';

const onSubmit: SubmitFunction<MyFormType> = async ({ formElement }) => {
...

<form method="POST" action="/" use:enhance={onSubmit}>

There isn’t a direct import for SubmitFunction, so…

Similar Posts

Loading similar posts...