Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does this code not throw an error? #367

Open
nwaokoron opened this issue Aug 19, 2024 · 1 comment
Open

Why does this code not throw an error? #367

nwaokoron opened this issue Aug 19, 2024 · 1 comment

Comments

@nwaokoron
Copy link

import { SignOut } from '@/utils/auth-helpers/server';

Pretty new to Next.js. I thought importing a server component in a client component
would cause an error but this code seems to allow it. How so?

@k-thornton
Copy link
Contributor

k-thornton commented Aug 23, 2024

Since you're new to Next.js this might be your first encounter with Server Actions
https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations#event-handlers

They're great, it makes it so you can write vanilla functions that run on your server and call them from your client side, instead of having to make a bunch of API endpoints and HTTP calls. That all happens behind the scenes. Once you're comfortable with server actions it's really hard to go back to API routes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants