react
react copied to clipboard
ReferenceError: navigator is not defined in Nextjs
I am creating form with formio in Nextjs project got this error, anyone see this problem, and any workaround?
error - ReferenceError: navigator is not defined
at Object.
I have the same problem, even using the 'use client' directive of nextjs.
You to load the form dynamically and avoid any SSR, you will get rid of that problem.
import dynamic from 'next/dynamic'
const Form = dynamic<FormioFormProps>(() => import('@formio/react').then(mod => mod.Form), {
ssr: false,
loading: () => <p>Loading...</p>,
})
You continue using your form like you usually do
/*your commponent*/
return ( <Form
formReady={onFormReady}
options={options} .....