
Dev Forum
Dev Forum
I'm building a Next.js application and want to add authentication. Has anyone implemented NextAuth.js with custom credentials provider? Any example code or best practices would be greatly appreciated.
Our application is facing performance issues with PostgreSQL as our dataset grows. We're currently using standard SELECT queries with multiple JOINs that worked fine with smaller datasets. What strategies should we implement for optimizing these queries?
I'm trying to understand when to use Server Components vs. Client Components in React. What are the best use cases for each, and how do they communicate with each other?
I'm trying to understand when to use Server Components vs. Client Components in React. What are the best use cases for each, and how do they communicate with each other?
react
server-components
next.js
react_architect
Server Components are great for data fetching, accessing backend resources directly, and keeping large dependencies server-side. Client Components should be used when you need interactivity, browser APIs, or React hooks.
frontend_lead
One pattern I've found effective is to use Server Components as containers that fetch data and pass it down to Client Components that handle the UI interactions. This gives you the best of both worlds.
next_expert
Remember that Server Components can't use hooks or browser APIs. They run only on the server and never on the client. Communication is one-way: Server Components can pass props to Client Components, but not vice versa.