Deployment & Environment Variables in Next.js Quiz – 15 Questions with Answers
15 questions · 12 min · Medium
Test your knowledge of state management in Next.js, including React useState, useReducer, Context API, URL state, server state, form state, Zustand, Redux Toolkit, and managing state across Server and Client Components.
No sign-up needed · Last updated:
Score: 0 00:00
Create a free account to keep your scores and track your progress. It is optional.
15 questions · 12 min · Medium
15 questions · 12 min · Medium
20 questions · 15 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
B. useState
The useState hook lets a Client Component store and update local state, causing React to render the component again when the state changes.
A. Context API
The Context API allows components to access shared values from a provider without explicitly passing those values through every intermediate component.
C. useReducer
The useReducer hook manages state through a reducer function that receives the current state and an action and returns the next state.
D. Search filters and pagination settings
URL search parameters can represent shareable state such as search queries, filters, sorting, and pagination. They also support browser navigation and bookmarking.
B. useSearchParams
The useSearchParams hook provides a read-only interface to the current URL's query parameters in a Client Component.
A. Redux Toolkit
Redux Toolkit provides recommended tools for creating Redux stores, reducers, and actions while reducing boilerplate.
C. Managing shared client-side state with a lightweight store
Zustand is a lightweight state management library that lets components subscribe to shared store state without requiring Redux-style boilerplate.
D. In a Client Component
A provider that uses client-side React state or hooks should be implemented as a Client Component and can wrap the relevant part of the application.
A. Data that originates from or is managed by a server, such as database records returned by an API
Server state represents data managed by a remote source. Applications often need fetching, caching, revalidation, and synchronization strategies to keep it current.
B. TanStack Query
TanStack Query provides tools for fetching, caching, synchronizing, and updating asynchronous server data. Its usage should be planned around the application's Server and Client Component architecture.
C. It may allow state to leak between requests or users
Server processes can handle multiple users. A shared mutable singleton may accidentally expose one request's state to another, so request-specific state should be isolated.
D. Use local component state
Temporary UI state, such as whether a dropdown is open, is usually best managed locally with useState or another suitable local-state mechanism.
A. To display an anticipated state update before an asynchronous operation finishes
The useOptimistic hook can display a temporary optimistic state while an action is in progress, improving perceived responsiveness before the final result arrives.
B. Server Components cannot use client-only hooks such as useState and useEffect
Server Components do not support client-only hooks such as useState and useEffect. Interactive state belongs in Client Components.
C. The type of state, its sharing requirements, and where it needs to be accessed
Choose a state solution based on the problem: local state for temporary UI behavior, URL state for shareable navigation state, and appropriate server-state or shared-state tools when needed.