Next.jsPage Router
Step 1: Embed Surface Tag
Add a Surface Tag to your Next.js Site
- Navigate to the
pages/_document.tsxfile. - Add the following code in the Start of
<head>tag section.
Check out the How to Get Site ID page to get your site ID.
import Document, { Html, Head, Main, NextScript } from "next/document";
import Script from "next/script";
export default class MyDocument extends Document {
render() {
return (
<Html lang="en">
<Head>
<Script
id="surface-tag"
src="https://cdn.jsdelivr.net/gh/trysurface/scripts@latest/surface_tag.min.js"
data-site-id="SITE_ID"
strategy="beforeInteractive"
/>
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
}Using a verified custom domain? Add data-custom-domain="forms.example.com" to the Surface Tag. Follow the custom-domain setup guide before publishing the change.
Ready to Get Started?
See it on your own site, or open the app and build the first form.