Skip to content

Instantly share code, notes, and snippets.

@BjornDCode
Created September 28, 2021 09:44
Show Gist options
  • Save BjornDCode/43482159a73f038a40ea4652774c898b to your computer and use it in GitHub Desktop.
Save BjornDCode/43482159a73f038a40ea4652774c898b to your computer and use it in GitHub Desktop.
Reform in NextJS
import { useEffect } from 'react'
import Script from 'next/script'
export default function Home() {
useEffect(() => {
window.Reform=window.Reform||function(){(Reform.q=Reform.q||[]).push(arguments)};
window.Reform('init', {
url: '', // Form URL
target: '#my-reform',
})
}, [])
return (
<div>
<Script
id="reform-script"
src="https://embed.reform.app/v1/embed.js"
strategy="afterInteractive"
/>
<main>
<div id="my-reform"></div>
</main>
</div>
)
}
@jrbaudin
Copy link

jrbaudin commented Oct 8, 2021

@ BjornDCode Thought I'd send a FYI the above gist. When running Next with TypeScript this version doesn't work since TS doesn't recognize Reform.q etc. I'm exploring fixes atm.
bild

@jrbaudin
Copy link

jrbaudin commented Oct 8, 2021

Quick fix is likely to just define

declare const Reform: any

At the top of the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment