# Scripts Loading third-party scripts in Next.js. ## Use next/script Always use `next/script` instead of native ` // Good: Next.js Script component import Script from 'next/script' ``` ## Don't Put Script in Head `next/script` should not be placed inside `next/head`. It handles its own positioning. ```tsx // Bad: Script inside Head import Head from 'next/head' import Script from 'next/script' // Good: Next.js component import { GoogleAnalytics } from '@next/third-parties/google' export default function Layout({ children }) { return ( {children} ) } ``` ## Google Tag Manager ```tsx import { GoogleTagManager } from '@next/third-parties/google' export default function Layout({ children }) { return ( {children} ) } ``` ## Other Third-Party Scripts ```tsx // YouTube embed import { YouTubeEmbed } from '@next/third-parties/google' // Google Maps import { GoogleMapsEmbed } from '@next/third-parties/google' ``` ## Quick Reference | Pattern | Issue | Fix | |---------|-------|-----| | `