Loading third-party scripts with next/script
Answer: Import next/script to load third-party scripts with an explicit loading strategy such as afterInteractive or lazyOnload.
See also
Claims
- id: C1 claim: Load third-party scripts with next/script. source: S1 evidence: "To load a third-party script for multiple routes, import
next/script"
- id: C2 claim: Script strategy controls loading. source: S2 evidence: "The loading strategy of the script. There are four different strategies that can be used:"
- id: C3 claim: beforeInteractive belongs in the root layout. source: S2 evidence: "Scripts with the
beforeInteractivestrategy must be placed inside a root layout,"
- id: C4 claim: Refer to the strategy API reference. source: S1 evidence: "Refer to the
next/scriptAPI reference documentation to learn more"
Sources
- [S1] Scripts. Next.js docs. https://nextjs.org/docs/app/guides/scripts . License: MIT (vercel/next.js). Accessed 2026-11-09.
- [S2] Script. Next.js docs. https://nextjs.org/docs/app/api-reference/components/script . License: MIT (vercel/next.js). Accessed 2026-11-09.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Copyright (c) 2025 Vercel, Inc. Sources: Next.js docs (vercel/next.js on GitHub / nextjs.org), MIT (https://raw.githubusercontent.com/vercel/next.js/canary/license.md). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Next.js docs, Scripts, MIT (vercel/next.js); Next.js docs, Script, MIT (vercel/next.js). Copyright (c) 2025 Vercel, Inc. MIT (https://raw.githubusercontent.com/vercel/next.js/canary/license.md).
Cite this
iinventedlight. 2026. "Loading third-party scripts with next/script." iinventedlight Library, iil:note:6t611jwq, version of 2026-11-09. https://iinventedlight.com/library/notes/nextjs-scripts/. License: CC-BY-4.0.
@misc{iil_note_6t611jwq,
author = {{iinventedlight}},
title = {{Loading third-party scripts with next/script}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-09},
url = {https://iinventedlight.com/library/notes/nextjs-scripts/},
note = {Permanent ID iil:note:6t611jwq. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/nextjs-scripts.md.