Hello guys, i'm trying to make an api with next.js but...
Unanswered
Kryp Arnold posted this in #help-forum
Hello again, if i don't specify at the top of the file with "use client", i can still use database or something in my component right?
15 Replies
Because i tried to build an app which uses server actions and it said Server actions is not supported on static export
but i think i can still use my database in server components
is it right?
@Kryp Arnold Because i tried to build an app which uses server actions and it said Server actions is not supported on static export
Serengeti
server components and server actions of course require a server. When you do a static export, you export your whole app to plain prerendered HTML and JS, which will only be loaded and run by the browser, there will be no server at all. That's the whole point of a static export.
Ah, but yes, you can use server in server components during build/export, yes
i cant use server actions on static exports but i can make api and the app seperate
and it will be safe right?
@Kryp Arnold and it will be safe right?
Serengeti
"safe" is irrelevant here. it's just wheter it will work or not 😛
Yes, you can of course deploy a separate API and call it from your client-side React components. That's how things have always worked 🙂
like php
@Kryp Arnold like php
Serengeti
PHP is not static
yeah i just dont have enough english to explain that sorry :D
Snowshoe
Yes @Kryp Arnold
If you are not specifying the component as "use client, " it means it's a server component.
But make sure this server component is not imported somewhere which is a client component
If you are not specifying the component as "use client, " it means it's a server component.
But make sure this server component is not imported somewhere which is a client component
ok thanks