as the title says I can't make hellosign-embedded
work with next
My app will be served though a CDN, so I don't cake if it won't work with SSR
const HelloSign: any = dynamic(
(): any => {
return import("hellosign-embedded")
},
{ ssr: false }
)
export default function Home() {
const client =
typeof window !== "undefined"
? new HelloSign({
allowCancel: false,
clientId: "HELLO SIGN CLIENT ID", // DEV HelloSign Client ID
skipDomainVerification: true,
})
: null
return null
}
I keep getting TypeError: HelloSign is not a constructor
I also created this issue on GitHub with further information
Edit:
I see now where things got confusing.
hellosign-embedded
references thewindow
object (i.e., the import needs to be visible only during the client-side compilation phase). I saw thatnext/dynamic
was being used to import a module. Sincedynamic()
returns a type ofComponentType
and the containingclient
variable was inside theHome
function, I had incorrectly assumed you were trying to import a React component.It turns out
hellosign-embedded
isn't even a React component at all so you shouldn't usenext/dynamic
. You should be able to use ES2020 imports instead. Yourpages/index.tsx
file will look something like this:disregard old answer:
HelloSign
is of typeComponentType
, so you can use the JSX element stored in the variable directly: