Results: {JSON.stringify(results, null, 2)}
Loading...
, } ) export default function Page() { return (Hello!
} ``` ```jsx filename="app/page.js" import dynamic from 'next/dynamic' const ClientComponent = dynamic(() => import('../components/hello').then((mod) => mod.Hello) ) ```Loading...
, }) export default function Home() { returnHello!
} // pages/index.js import dynamic from 'next/dynamic' const DynamicComponent = dynamic(() => import('../components/hello').then((mod) => mod.Hello) ) ``` ## With no SSR To dynamically load a component on the client side, you can use the `ssr` option to disable server-rendering. This is useful if an external dependency or component relies on browser APIs like `window`. ```jsx 'use client' import dynamic from 'next/dynamic' const DynamicHeader = dynamic(() => import('../components/header'), { ssr: false, }) ``` ## With external libraries This example uses the external library `fuse.js` for fuzzy search. The module is only loaded in the browser after the user types in the search input. ```jsx import { useState } from 'react' const names = ['Tim', 'Joe', 'Bel', 'Lee'] export default function Page() { const [results, setResults] = useState() return (Results: {JSON.stringify(results, null, 2)}