Installations
npm install felte
Score
86.8
Supply Chain
81.7
Quality
83.4
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Developer
Developer Guide
Module System
ESM, UMD
Min. Node Version
^12.20.0 || ^14.13.1 || >=16.0.0
Typescript Support
Yes
Node Version
22.10.0
NPM Version
10.9.0
Statistics
1,018 Stars
838 Commits
43 Forks
6 Watching
23 Branches
30 Contributors
Updated on 27 Nov 2024
Bundle Size
25.06 kB
Minified
8.10 kB
Minified + Gzipped
Languages
TypeScript (86.37%)
Astro (5.41%)
JavaScript (4.78%)
Svelte (1.75%)
CSS (1.7%)
Total Downloads
Cumulative downloads
Total Downloads
856,657
Last day
-14.5%
1,706
Compared to previous day
Last week
-8.7%
8,969
Compared to previous week
Last month
12.5%
41,282
Compared to previous month
Last year
80.6%
439,632
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Felte: A form library for Svelte, Solid and React
Felte is a simple to use form library for Svelte, Solid and React. No Field
or Form
components are needed, just plain stores and actions to build your form however you like. You can see it in action in this CodeSandbox demo!
Features
- Single action to make your form reactive.
- Use HTML5 native elements to create your form. (Only the
name
attribute is necessary). - Provides stores and helper functions to handle more complex use cases.
- No assumptions on your validation strategy. Use any validation library you want or write your own strategy.
- Handles addition and removal of form controls during runtime.
- Official solutions for error reporting using
reporter
packages. - Well tested. Currently at 99% code coverage and constantly working on improving test quality.
- Supports validation with yup, zod, superstruct and vest.
- Easily extend its functionality.
Simple usage example
Svelte
1<script> 2 import { createForm } from 'felte'; 3 4 const { form } = createForm({ 5 onSubmit: async (values) => { 6 /* call to an api */ 7 }, 8 }); 9</script> 10 11<form use:form> 12 <input type="text" name="email" /> 13 <input type="password" name="password" /> 14 <button type="submit">Sign In</button> 15</form>
Solid
1import { createForm } from '@felte/solid'; 2 3function Form() { 4 const { form } = createForm({ 5 onSubmit: async (values) => { 6 /* call to an api */ 7 }, 8 }); 9 10 return ( 11 <form use:form={form}> 12 <input type="text" name="email" /> 13 <input type="password" name="password" /> 14 <button type="submit">Sign In</button> 15 </form> 16 ); 17}
[!IMPORTANT]
To use the
use-*
directive on Solid. You need to extend the JSX namespace. For example:
1// src/global.d.ts 2declare global { 3 declare module "solid-js" { 4 namespace JSX { 5 interface Directives { 6 form: (node: HTMLFormElement) => void; 7 } 8 } 9 } 10}
React/Preact
1import { useForm } from '@felte/react'; 2// if using preact, use `@felte/preact` 3 4function Form() { 5 const { form } = useForm({ 6 onSubmit: async (values) => { 7 /* call to an api */ 8 }, 9 }); 10 11 return ( 12 <form ref={form}> 13 <input type="text" name="email" /> 14 <input type="password" name="password" /> 15 <button type="submit">Sign In</button> 16 </form> 17 ); 18}
Vue
1<script setup> 2 import { useForm } from '@felte/vue'; 3 4 const { vForm } = useForm({ 5 onSubmit: async (values) => { 6 /* call to an api */ 7 }, 8 }); 9</script> 10<template> 11 <form v-form> 12 <input type="text" name="email" /> 13 <input type="password" name="password" /> 14 <button type="submit">Sign In</button> 15 </form> 16</template>
VanillaJS with Web Components
1<script type="module"> 2 import 'https://unpkg.com/@felte/element@0.4.0/dist/min/felte-form.js'; 3 const felteForm = document.querySelector('felte-form'); 4 5 felteForm.configuration = { 6 onSubmit: async (values) => { 7 console.log(values); 8 }, 9 }; 10</script> 11 12<felte-form> 13 <form> 14 <input type="text" name="email" /> 15 <input type="password" name="password" /> 16 <button type="submit">Sign In</button> 17 </form> 18</felte-form>
This example works without a bundler! Copy its contents to an HTML file and open it on your browser. A more complete example like this, with validation and error reporting, can be found here.
More examples
You can find fully functional examples on the /examples directory of this repository. You should be able to open them on CodeSandbox by replacing github's url to githubbox
. E.g. Replace https://github.com/pablo-abc/felte/tree/main/examples/svelte/basic
with https://githubbox.com/pablo-abc/felte/tree/main/examples/svelte/basic
.
Packages
This repository is a mono-repo containing multiple packages located in the packages
directory. Maintained using pnpm and Changesets.
Svelte
We provide two packages that are specific to Svelte:
felte
This is the core package that contains all the basic functionality you need to handle your forms in Svelte. Felte optionally allows you to use error reporters (see them as plugins) to prevent you from needing to find a way to display your errors on your form manually. For this we provide already some reporter packages contained in this same repo.
@felte/reporter-svelte
A reporter package that uses a Svelte component to pass the validation messages for you to display. This provides an API that might feel the most familiar to most developers.
Solid
We provide two packages that are specific to Solid:
@felte/solid
This is the core package that contains all the basic functionality you need to handle your forms in Solid. Same as felte
but specifically made for Solid.
@felte/reporter-solid
A reporter package that uses a Solid component to pass the validation messages for you to display. This provides an API that might feel the most familiar to most developers.
React
We provide two packages that are specific to React:
@felte/react
This is the main package that contains the basic functionality you need to handle your forms in React. Same as felte
but specifically made for React.
@felte/reporter-react
A reporter packages that uses a React component to pass the validation messages for you to display. This provides an API that might feel the most familiar to most developers.
Preact
We provide two packages that are specific to Preact:
@felte/preact
This is the main package that contains the basic functionality you need to handle your forms in Preact. Same as felte
but specifically made for Preact. The API is the same as @felte/react
so you can refer to the same documentation.
@felte/reporter-preact
A reporter packages that uses a Preact component to pass the validation messages for you to display. This provides an API that might feel the most familiar to most developers. The API is the same as @felte/react
so you can refer to the same documentation.
Vue
We provide (experimental) support for Vue with the following package:
@felte/vue
This is package contains the basic functionality you need to handle your forms in Vue. Same as felte
but specifically made for Vue. The API is similar to that of felte
but using a custom directive to register your form and returning "accessors" (similar to the react/preact/solid packages) that resolve into reactive ref
s.
There's no documentation for this right now so use at your own risk.
VanillaJS
We provide three packages that can be used with only VanillaJS. Two of them using Web Components. These elements do not use the shadow DOM since there is no reason to isolate styles.
@felte/element
This is the main package that contains the basic functionality you need to handle your forms in vanilla JS using a custom element. Similar to felte
but specifically made to be used as a custom element. This is the recommended way to handle your forms when using Vanilla JS. Web components are well supported by all major browsers so this should be a safe option unless you need to support legacy browsers.
@felte/reporter-element
A reporter packages that uses a custom element to display validation messages on the DOM. This the recommended way to display your validation messages when using vanilla JS.
@felte/vanilla
This is the main package that contains the basic functionality you need to handle your forms in vanilla JS. Similar to felte
and other integrations but with all code related to frameworks removed. This requires a bit more work to use, since you'll be the one in charge of cleaning up subscribers and listeners on it. It's API is basically the same as felte
(Svelte's integration) so you can use Svelte's documentation as a reference. This can be used as a starting point to create your own integration/package for other environments. When it comes to vanilla JS we'd recommend using @felte/element
using web components.
Validators
The following packages can be used with any of the framework specific felte
wrappers:
@felte/validator-yup
A utility package to help you validate your form with Yup.
@felte/validator-zod
A utility package to help you validate your form with Zod.
@felte/validator-superstruct
A utility package to help you validate your form with Superstruct.
@felte/validator-vest
A utility package to help you validate your form with Vest.
Reporters
The following packages can be used with any of the framework specific felte
wrappers:
@felte/reporter-tippy
A reporter that uses Tippy.js to display your validation messages without needing any extra work.
@felte/reporter-cvapi
A reporter that uses the browser's constraint validation API to display your validation messages.
@felte/reporter-dom
A reporter that displays the error messages in the DOM, either as a single element or a list of elements.
Contributing
If you want to contribute to this project you may check CONTRIBUTING.md
for general guidelines on how to do so.
Contributors ✨
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
License
MIT
Browser support
While further testing would be needed to provide an accurate answer, Felte should work in all evergreen browsers. Polyfills might be needed if you target older browsers such as IE 11 for, at least, Promise.all
, Element.closest
, URLSearchParams
, fetch
, CustomEvent
and iterators.
No vulnerabilities found.
Reason
19 commit(s) and 3 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Info: FSF or OSI recognized license: MIT License: LICENSE.md:0
Reason
Found 6/30 approved changesets -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/test.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/pablo-abc/felte/test.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/pablo-abc/felte/test.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:38: update your workflow using https://app.stepsecurity.io/secureworkflow/pablo-abc/felte/test.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/test.yml:29
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 7 are checked with a SAST tool
Reason
20 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-mv48-hcvh-8jj8
- Warn: Project is vulnerable to: GHSA-353f-5xf4-qw67
- Warn: Project is vulnerable to: GHSA-c24v-8rfc-w8vw
- Warn: Project is vulnerable to: GHSA-8jhw-289h-jh2g
- Warn: Project is vulnerable to: GHSA-64vr-g452-qvp3
- Warn: Project is vulnerable to: GHSA-9cwx-2883-4wfx
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-5v2h-r2cx-5xgj
- Warn: Project is vulnerable to: GHSA-rrrm-qjm4-v8hf
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-8266-84wp-wv5c
- Warn: Project is vulnerable to: GHSA-g3ch-rx76-35fx
- Warn: Project is vulnerable to: GHSA-m95q-7qp3-xv42
Score
4
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More