Server actions
Unanswered
American black bear posted this in #help-forum
American black bearOP
I am learning about server actions, i implement what next js have in the documentation but it is not working
42 Replies
American black bearOP
each time a press the botton to active the action i get the error
i know that in next 14 is statable but in my version with experimental it should work
@American black bear I am learning about server actions, i implement what next js have in the documentation but it is not working
This code works for me in that version
American black bearOP
this is what a got
// ./page.jsx
export default function Home() {
async function myAction() {
"use server";
console.log("hellog");
}
return (
<form action={myAction}>
<button type="submit">Add to cart</button>
</form>
);
}You might have some additional config somewhere that's causing the issue. You might also want to try deleting the .next folder and rebuilding
@American black bear Click to see attachment
actually, remove the
images property from thisI think pathname should be
"/chart/**" instead of "/chart**"American black bearOP
still getting same error
@American black bear still getting same error
Did you try removing it? or the pathname? or both
American black bearOP
Mmm it look like the error is not throwed by the server action
It is like a error of next js
Shy Albatross
you can try Next 14 since in 14 server actions are stable, not experimental
code looks fine
American black bearOP
I would love to use 14, but i hace see that next 14 has some problema with next auth
Shy Albatross
I see
I can't see anything wrong with the code, it doesn't like your server action and that's it
I'd delete
.next and node_modules and do a npm install againAmerican black bearOP
yeah i also did that a few times
Shy Albatross
Node.js version then, maybe?
@Shy Albatross Node.js version then, maybe?
I always forget to check that
American black bearOP
18.16.0
@American black bear 18.16.0
upgrade to 19 or 20
Shy Albatross
still, 18 shouldn't be an issue
at least it should fail in a more obvious manner
OP put your code on a public repo and link it here
or first try to do a minimal reproduction with a create-next-app fresh app and just make a server action etc. just like you did
@Shy Albatross still, 18 shouldn't be an issue
I ran into issues with 18
sounds like a windows issue honestly
node 18 + windows is a known combo where nextjs doesn't work reliably for the past few months
Shy Albatross
interesting, I'm on Windows too, but Node 20
@Shy Albatross interesting, I'm on Windows too, but Node 20
I haven't had any issues after going up to 20
American black bearOP
yeah now we have a diferent error
Shy Albatross
ayyy at least not a 500
American black bearOP
finally works, next is just 

Shy Albatross
wha-
you mean commenting out the input fixed it?
American black bearOP
not sure, i create other proyect and then then pase all the code that i have
Shy Albatross
I swear, sometimes I just want to go back to next 12 and stay there
American black bearOP
jajajaja same