Within the layout.tsx
file located in the main directory of the app
folder, it is common practice to include scripts since you have the ability to insert <head>
tags within.
If there is a need to add scripts on specific pages, you can directly utilize the Script
component.
By default, the Script
component will use an afterInteractive
strategy which ensures that your script loads after the page has finished loading. However, if you prefer the script to be included in the head of the document, you can opt for the beforeInteractive
strategy. This strategy will always place the script in the head section, regardless of its location within the component hierarchy.