Next.jsPage Router

Step 3: Optimize

Optimize Surface Form loading speed

  1. Navigate to the pages/_document.tsx file.
  2. Add the following <link> tags in the Start of <head> tag section.
// pages/_document.tsx
import { Html, Head, Main, NextScript } from 'next/document'

export default function Document() {
  return (
    <Html lang="en">
      <Head>
        {/* Speed up connections to forms.withsurface.com */}
        <link rel="dns-prefetch" href="https://forms.withsurface.com" />
        <link rel="preconnect" href="https://forms.withsurface.com" crossOrigin="" />

        {/* Prefetch a form in advance */}
        <link
          rel="prefetch"
          href="REPLACE ME WITH FORM URL"
          as="document"
        />
      </Head>
      <body>
        <Main />
        <NextScript />
      </body>
    </Html>
  )
}

Replace REPLACE ME WITH FORM URL with a Surface Form URL.

If the form uses a custom domain, replace forms.withsurface.com in the connection hints with your verified domain. See Use the Surface Tag with a Custom Domain.

Ready to Get Started?

See it on your own site, or open the app and build the first form.

Need Help?

Setup problems, blocked domains and CRM push failures live in the Help Center.

Feature Requests?

Tell us what is missing. We would rather hear it than guess.