I am trying to use emailjs in my NextJS application to which you can find the repo here. When I deploy the application to Vercel, it throws an error saying I cannot use an import statement outside a module and seems to point to the emailjs import as the source of the error.
I went ahead and did a dynamic import of emailjs like this:
import dynamic from "next/dynamic";
const emailjs = dynamic(
() => import("emailjs-com").then((component) => component.emailjs),
{ ssr: false }
);
With the dynamic import like this, I am able to deploy to Vercel w/o errors. However, my emailjs code does not work anymore and throws an error that says "emailjs.sendForm is not a function" when the relevant code gets executed. How can I use emailjs with NextJS properly?

require("emailjs")instead ofimport