#react-hook-form not working with Astro and React
3 messages · Page 1 of 1 (latest)
Hi @spark thorn. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Based on the information provided, it seems there have been issues reported with integrating react-hook-form with preact in the Astro ecosystem. The error reported was: Cannot find package 'react' imported from \node_modules\react-hook-form\dist\index.esm.mjs. A similar issue was found on StackOverflow but the proposed solution did not fix the problem. The user was unsure if Astro is supposed to work with preact and react-hook-form at all or if this scenario is incompatible (source (https://github.com/withastro/astro/issues/8901)).
In another issue, a user reported a problem with a ComboBox component from react-aria when trying to render with client:load using the @astrojs/preact adapter with { compat: true }. The issue was resolved by swapping out preact({ compat: true }) with just react() (source (https://github.com/withastro/astro/issues/4107)).
Astro supports server-side rendering (SSR) and has a guide on how to build HTML forms in Astro pages in SSR mode (source (https://docs.astro.build/en/recipes/build-forms#_top)). Before deploying your Astro site with SSR enabled, you need to install the appropriate adapter and add it to your astro.config.mjs file (source (https://docs.astro.build/en/guides/deploy#adding-an-adapter-for-ssr)).