0
0
NextJSframework~10 mins

Client-only modules in NextJS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import a client-only component in Next.js.

NextJS
import dynamic from 'next/dynamic';
const ClientComponent = dynamic(() => import('[1]'), { ssr: false });
Drag options to blanks, or click blank then click option'
A'./ClientComponent'
B'next/server'
C'react'
D'next/head'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the component directly without dynamic import.
Forgetting to set ssr: false.
Using server-only modules as client components.
2fill in blank
medium

Complete the code to disable server-side rendering for a client-only component.

NextJS
const ClientOnly = dynamic(() => import('./ClientOnly'), { [1]: false });
Drag options to blanks, or click blank then click option'
Afallback
Bloading
Csuspense
Dssr
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'loading' or 'fallback' instead of 'ssr'.
Not disabling SSR causes the component to render on the server.
3fill in blank
hard

Fix the error in the dynamic import to correctly load a client-only module.

NextJS
const ClientWidget = dynamic(() => import('./ClientWidget'), { ssr: [1] });
Drag options to blanks, or click blank then click option'
Afalse
Btrue
Cnull
Dundefined
Attempts:
3 left
💡 Hint
Common Mistakes
Setting ssr to true causes server rendering errors.
Using null or undefined does not disable SSR.
4fill in blank
hard

Fill both blanks to create a client-only component with a loading fallback.

NextJS
const ClientOnlyComp = dynamic(() => import('./ClientOnlyComp'), { [1]: false, [2]: () => <p>Loading...</p> });
Drag options to blanks, or click blank then click option'
Assr
Bloading
Cfallback
Dsuspense
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing 'loading' with 'fallback'.
Not disabling SSR causes the component to render on the server.
5fill in blank
hard

Fill all three blanks to import a client-only component with SSR disabled, a fallback UI, and suspense enabled.

NextJS
const FancyClient = dynamic(() => import('./FancyClient'), { [1]: false, [2]: () => <p>Loading fancy UI...</p>, [3]: true });
Drag options to blanks, or click blank then click option'
Assr
Bfallback
Csuspense
Dloading
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to disable SSR.
Using 'fallback' instead of 'loading'.
Not enabling suspense when needed.