npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

faurm

v0.1.2

Published

Faurm brings a small sets of function and barebone components to help you write clean and accessible forms

Downloads

36

Readme

Faurm

faurm (pronounced like "form" or "foarm") is a simple library that aims to enhance the already great Remote Form from the even greater SvelteKit It's a form wrapper around SvelteKit preflight front-end validation. It adds DX niceties, namely timers, callbacks and more.

Before we begin

Remote form function are still in their infancy. This library's API, like the tech it depends on is subject to frequent breaking changes.

Installation

npm install faurm

Get Started

Write a schema of you file using any standard schema compliant library

// ./lib/schema.ts
import z from "zod/v4";

export const createTodoFormSchema = z.object({
    title: z.string('The title field must be a string.')
        .min(1, 'The title field is required'),
});

Pass your schema to a remote form function.

// ./lib/todos.remote.ts
import {createTodoFormSchema} from "./schema.js";
import {form} from "$app/server";

export const createTodo = form(createTodoFormSchema, (data) => {
    return {
        ...data
    }
});

Enhance your form using the useFaurm wrapper.

<script lang="ts">
    import {createTodo} from "./lib/todos.remote.js";
    import {useFaurm} from "faurm";

    const form = useFaurm(createTodo, {
        initialData: {
            title: "A first todo"
        },
    })
    const {fields, enhance} = form;

</script>

<form {...enhance}>
    <label>
        Title
        <input {...fields.title.as('text')}
               aria-describedby={fields.title.issues() ? `invalid-title-helper` : null}/>
        {#if fields.title.issues() !== undefined }
            <small id={`invalid-title-helper`}>
                {(fields.title.issues() ?? []).map(i => i.message).join(', ')}
            </small>
        {/if}
    </label>

    <input type="submit" value="Create"/>
</form>


```sveltehtml
To enable front-end validation, pass your schema to the useFaurm wrapper
<script lang="ts">
    import {createTodo} from "./lib/todos.remote.js";
    import {useFaurm} from "faurm";
    import {createTodoFormSchema} from "./lib/schema.js";

    const form = useFaurm(createTodo, {
        validate: createTodoFormSchema,
        initialData: {
            title: "hello world"
        },
    })

    const {fields, enhance} = form;
</script>

<form {...enhance}>
    <label>
        Title
        <input {...fields.title.as('text')}
               aria-describedby={fields.title.issues() ? `invalid-title-helper` : null}/>
        {#if fields.title.issues() !== undefined }
            <small id={`invalid-title-helper`}>
                {(fields.title.issues() ?? []).map(i => i.message).join(', ')}
            </small>
        {/if}
    </label>


    <input type="submit" value="Create"/>
</form>

Event handlers allow you to react to your form submissions and their potential results

<script lang="ts">
    import {createTodo} from "./lib/todos.remote.js";
    import {useFaurm} from "faurm";

    const form = useFaurm(createTodo, {
        initialData: {
            title: "hello world"
        },
        onSubmit(data){
            console.log({submitted: data})
        },
        onValidationError(){
            console.log({issues: fields.title.issues()});
        },
        onSuccess(){
            console.log({result : createTodo.result});
        },
    })

    const {fields, enhance} = form;

</script>

<form {...enhance}>
    <label>
        Title
        <input {...fields.title.as('text')}
               aria-describedby={fields.title.issues() ? `invalid-title-helper` : null}/>
        {#if fields.title.issues() !== undefined }
            <small id={`invalid-title-helper`}>
                {(fields.title.issues() ?? []).map(i => i.message).join(', ')}
            </small>
        {/if}
    </label>
    <input type="submit" value="Create"/>
</form>

The timers object can be used to indicate loading state. You can use it to disable inputs, buttons or show messages !

<script lang="ts">
    import {createTodo} from "./lib/todos.remote.js";
    import {useFaurm} from "faurm";
    import {createTodoFormSchema} from "./lib/schema.js";

    const form = useFaurm(createTodo, {
        validate: createTodoFormSchema,
        initialData: {
            title: "hello world"
        },
        delay: 500,
        timeout: 3000
    })

    const {fields, enhance, timers} = form;
</script>

<form {...enhance}>
    <label>
        Title
        <input {...fields.title.as('text')}
               aria-describedby={fields.title.issues() ? `invalid-title-helper` : null}/>
        {#if fields.title.issues() !== undefined }
            <small id={`invalid-title-helper`}>
                {(fields.title.issues() ?? []).map(i => i.message).join(', ')}
            </small>
        {/if}
    </label>


    <input type="submit" value="{timers.submitting ? 'loading': 'Create'}"/>
    {#if timers.delayed}
        <p>Loading, with a small delay</p>
    {/if}

    {#if timers.timeout}
        <p>It's been 3 seconds already ? </p>
    {/if}
</form>

We provide a set of barebone components to help you build accessible forms.

<script lang="ts">
    import {useFaurm} from "faurm";
    import {Control, Description, Errors, Field, Fieldset, Label, Legend} from "faurm";

    import {createProfile} from "./lib/profil.remote.js";
    import {createProfileFormSchema} from "./lib/schema.js";
    
    const form = useFaurm(createProfile, {
        validate: createProfileFormSchema,
        initialData: {
            name: "Alex"
        },
        delay: 500,
        timeout: 3000
    })
</script>

<form {...form.enhance} enctype="multipart/form-data">
    <Field {form} name="name">
        <Control>
            {#snippet children({props, field})}
                <Label>What is your name</Label>
                <input autocomplete="given-name" {...props} {...field.as('text')}/>
            {/snippet}
        </Control>
        <Description>Your given birth name</Description>
        <Errors/>
    </Field>

    <Field {form} name="bio">
        <Control>
            {#snippet children({props, field})}
                <Label>Biography</Label>
                <textarea {...props} {...field.as("text")}></textarea>
            {/snippet}
        </Control>
        <Description>Tell us about yourself</Description>
        <Errors/>
    </Field>

    <Fieldset {form} name="favorite_framework">
        <Legend>What is your favorite framework</Legend>
        <Control>
            {#snippet children({props, field})}
                <input {...props} {...field.as('radio', 'SvelteKit')}/>
                <Label>SvelteKit</Label>
            {/snippet}
        </Control>
        <Control>
            {#snippet children({props, field})}
                <input {...props} {...field.as('radio', 'Svelte')}/>
                <Label>Svelte</Label>
            {/snippet}
        </Control>
        <Control>
            {#snippet children({props, field})}
                <input {...props} {...field.as('radio', 'Kit')}/>
                <Label>Kit</Label>
            {/snippet}
        </Control>
        <Errors />
    </Fieldset>

    <Fieldset {form} name="privacy_options">
        <Legend>I agree to</Legend>
        <Control>
            {#snippet children({props, field})}
                <input {...props} {...field.as('checkbox', 'marketing')}/>
                <Label>Receive marketing emails</Label>
            {/snippet}
        </Control>
        <Control>
            {#snippet children({props, field})}
                <input {...props} {...field.as('checkbox', 'newsletter')}/>
                <Label>Receive our daily newsletter</Label>
            {/snippet}
        </Control>
        <Control>
            {#snippet children({props, field})}
                <input {...props} {...field.as('checkbox', 'all')}/>
                <Label>Receive all emails</Label>
            {/snippet}
        </Control>

        <Errors />
    </Fieldset>

    <Field {form} name="profile_picture">
        <Control>
            {#snippet children({props, field})}
                <Label>Profile Picture</Label>
                <input {...props} {...field.as('file')}/>
            {/snippet}
        </Control>
        <Description>Please provide a recent picture of yourself</Description>
        <Errors />
    </Field>
    <input type="submit" value="Submit"/>
</form>

Features

  • [X] Typesafe form enhancer with callbacks and timers
  • [X] Integrate new Svelte Kit form functionalities ? Client driven single flight mutation could be used
  • [X] Accessible components
  • [ ] Extract constraints from our validation
  • [ ] Draw the rest of the owl

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Who are we ?

We are the French digital agency GRAUW. We love to build websites and apps, mainly using Laravel, Vue and SvelteKit. Feel free to reach out ! GRAUW.