
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@simonlc/react-hook-form-persist
Advanced tools
Persist and populate react-hook-form form using storage of your choice
Persist and populate react-hook-form form using storage of your choice
Install the package locally within you project folder with your package manager:
With npm:
npm install @simonlc/react-hook-form-persist
With yarn:
yarn add @simonlc/react-hook-form-persist
With pnpm:
pnpm add @simonlc/react-hook-form-persist
import React from "react";
import ReactDOM from "react-dom";
import { useForm } from "react-hook-form";
import useFormPersist from "@simonlc/react-hook-form-persist";
function App() {
const { register, handleSubmit, watch, errors, setValue } = useForm();
useFormPersist("storageKey", {
watch,
setValue,
storage: window.localStorage, // default window.sessionStorage
exclude: ["baz"],
});
const onSubmit = (data) => {
console.log(data);
};
return (
<form onSubmit={handleSubmit(onSubmit)}>
<label>
foo:
<input name="foo" ref={register} />
</label>
<label>
bar (required):
<input name="bar" ref={register({ required: true })} />
</label>
{errors.required && <span>This field is required</span>}
<label>
baz (excluded):
<input name="baz" ref={register} />
</label>
<input type="submit" />
</form>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
Persist all form fields:
useFormPersist("form", { watch, setValue });
Persist all form fields except password:
useFormPersist("form", { watch, setValue, exclude: ["password"] });
Persist only the email field:
useFormPersist("form", { watch, setValue, include: ["email"] });
TODO
Got an idea for a new feature? Found a bug? Contributions are welcome! Please open up an issue or make a pull request.
FAQs
Persist and populate react-hook-form form using storage of your choice
We found that @simonlc/react-hook-form-persist demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.