Next.js Integration
Optimized tracking implementation for Next.js applications (both App Router and Pages Router).
App Router (Next.js 13+)
Insert the script into your primary layout.tsx. Next.js ensures the script is loaded exactly once and prevents it from blocking your page rendering layout.
app/layout.tsx
import Script from 'next/script'
export default function RootLayout({ children }) {
return (
<html lang="en">
<head>
<Script
src="https://dashfast.cz/script.js"
data-domain="vasedomena.cz"
data-api-key="YOUR_ID"
strategy="afterInteractive"
/>
</head>
<body>{children}</body>
</html>
)
}Pages Router
When using the Pages Router, append the script component inside your _app.tsx file. This ensures accurate session tracking across all route state changes.
pages/_app.tsx
import Script from 'next/script'
function MyApp({ Component, pageProps }) {
return (
<>
<Script
src="https://dashfast.cz/script.js"
data-domain="vasedomena.cz"
data-api-key="YOUR_ID"
strategy="afterInteractive"
/>
<Component {...pageProps} />
</>
)
}SPA Routing
The Script element configured with the afterInteractive strategy takes care of seamless dynamic loading. Furthermore, the DashFast script native runtime automatically monitors active URL updates (pushState), allowing full compatibility with Next.js without custom wrapper logic.