Next.js · Middle · Question 35 of 75
What happens when you import a server component into a 'use client' file?
- ✓Correct answer: It becomes a client component, and server code breaks or leaks
- 2It stays a server component: Next.js splits the modules at build time
- 3The import is ignored, and the component doesn't render
Explanation
Everything imported from a client module goes into the client bundle. If the component accessed the DB, the build fails (or worse, the code reaches the browser). Pass a server component to a client one as children or another prop from a server parent.