Keep the browser-only code in a Client Component (`'use client'`). If the library touches `window` at import time, load it with `dynamic(() => import(...), { ssr: false })`. Avoid importing browser-only modules from Server Components, and keep the client boundary as small as possible to limit shipped JS.
Expanding on the short answer — what usually matters in practice:
A tiny example (an explanation template):
// Example: discuss trade-offs for "browser-only-library-in-app-router:-how-do-you-u"
function explain() {
// Start from the core idea:
// Keep the browser-only code in a Client Component (`'use client'`). If the library touches
}