> For the complete documentation index, see [llms.txt](https://doc-old.keycloakify.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc-old.keycloakify.dev/documentation/v11/faq-and-help/can-i-use-react-hooks-form.md).

# Can I use react-hooks-form?

You can but it's probably not a good idea.\
The Keycloak server is authoritative for defining if a given input is valid, not your theme.\
For example, it's on the Keycloak server that you would defines that user passwords must be at least 12 character long or that you only accept registration from emails *@your-company.com*.\
You don't want to hard code those rules in your theme just to be able to display errors in realtime as the user fills the form, it will be a nightmare to maintain because you'll have to keep your theme in sync with your Keycloak server configuration.

\
The validation criteria are made accessible to the clients in `kcContext.profile.attributesByName[*].validators` and `kcContext.passwordPolicies`.\
Implementing those validator manually within `react-hooks-form` isn't straight forward. There's a lot of cases and the format is specific to Keycloak.

\
What you want to do instead is use the [useUserProfileForm hook](https://github.com/keycloakify/keycloakify/blob/8eaaffb25a7b6d6c8b7e455d5005dc31d70b8927/src/login/UserProfileFormFields.tsx#L20-L27) provided by Keycloakify which is akin to the react-hooks-form API wise but already implements all the Keycloak validators and password policies.

Beyond that don't feel the need to implement every possible input fields like checkboxes, multi-value, etc. You can just implement the subset fields type your client or company actually uses.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc-old.keycloakify.dev/documentation/v11/faq-and-help/can-i-use-react-hooks-form.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
