Calling actions via forms not working in server islands
Closed this issue · 3 comments
Astro Info
Astro v5.0.5
Node v22.12.0
System macOS (arm64)
Package Manager npm
Output static
Adapter @astrojs/node
Integrations none
Describe the Bug
When I submit an action via a form in a server island, the action isn’t called. Clicking on the logout
button doesn’t call t the action. Therefore the cookie isn’t deleted and the user isn’t logged out.
What's the expected result?
The action is called correctly by the form, since the form is server rendered via server islands.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-ygdn4aze?file=src%2Fpages%2Findex.astro
Participation
- I am willing to submit a pull request for this issue.
Note that the minimal reproducible example doesn’t work correctly on Stackblitz, but locally. (same issue as outlined here: #12371 (comment))
Your action can't be called from an HTML form on a page rendered on-demand. You'll have to disable prerendering on this page, or replace your form submission with a client-side script.
Pages must be on-demand rendered when calling actions using a form action. Ensure prerendering is disabled on the page before using this API.
See: https://docs.astro.build/en/guides/actions/#call-actions-from-an-html-form-action
@TheOtterlord Thanks for clarifying. I had read that paragraph, but was missing a note about server islands, since server islands are on-demand rendered. It would help a lot to add a about note server islands at this place in the documentation :)