Skip to content

Issue with Next.js and Autoform: Use of FormProvider in Server Components #128

Description

@baptisthecht

When using Next.js, integrating Autoform causes crashes due to the import of FormProvider (from react-hook-form) within a server component.

Temporary Solution
I had to manually add "use client" at the top of autoform/utils.ts and autoform/AutoForm.tsx files to resolve the issue.

Explanation
Next.js defaults to server components, but contexts like FormProvider cannot be used in server components. Changing these components to client components by adding "use client" fixed the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions