Skip to content
Playground Form Builder

Remote functions

Terminal window
npm i @sjsf/sveltekit

Required peer dependencies: @sjsf/form@^3.3.0 @sveltejs/kit@^2.48.3 esm-env@^1.2.0 svelte@^5.44.0

<script lang="ts">
import { BasicForm, createForm } from "@sjsf/form";
// WARN: You must export this ID Builder in your `defaults` file
import { createFormIdBuilder } from "@sjsf/sveltekit/rf";
import { connect } from "@sjsf/sveltekit/rf/client";
import * as defaults from "$lib/form-defaults";
import { createPost, getInitialData } from "./data.remote";
const initialData = await getInitialData();
const form = createForm(
await connect(createPost, {
...defaults,
...initialData,
idBuilder: createFormIdBuilder,
})
);
</script>
<BasicForm {form} novalidate />
  • experimental.async does not apply to dependency code - issue.

    Add this to your vite.config.js

    optimizeDeps: {
    exclude: ['@sjsf/form', '@sjsf/sveltekit/rf/client'],
    }
  • The form.value type on the client side is unknown because the RemoteForm type does not include information about the validator’s output type. For now, you need to specify the type manually: createForm<FormValue>(...).