Next.js Discord

Discord Forum

First time with Server Components. Please help

Unanswered
Alaska pollock posted this in #help-forum
Open in Discord
Alaska pollockOP
Hey everyone. Im starting a new project and have decided to take the leap and use server components. However, Im so confused. Im wondering if I could get some feedback on the pattern Im trying to use.

Im building a simple blog generator. My main view will render a blog generator form which takes blog preferences from the user. Once the form is submitted I want to call out to my API to return the newly created blog and render the contents in the main view.

The issue Im having is how on earth do I use this kind of pattern with server components? Am I over complicating this. Or would this not be possible with server components. Any advice on best practises would be highly appreciated.

4 Replies

Alaska pollockOP
Note: I understand that the screenshot will need to use 'use-client' in order to get it working. Im just wondering if its possible to do this kind of thing without.
European sprat
If you really want to make sure it's all server components you can try and use Server Actions: https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions

but generally for interactivity with forms and such i think people stick with client components. You can read more about when to use either here: https://nextjs.org/docs/getting-started/react-essentials#when-to-use-server-and-client-components
Alaska pollockOP
Amazing. Thats very reassuring. Thanks
@Alaska pollock Amazing. Thats very reassuring. Thanks
Since you are new a thing i do is that i start with a server component, and try to reduce everything to as small as i can get it. LIke a button which calls an api.. i would make a new component just with a button with a onClick being a client component and call it in the server component. Try this out