next-safe-action: [BUG] Sending form with javascript disabled not working
Are you using the latest version of this library?
- I verified that the issue exists in the latest next-safe-action release
Is there an existing issue for this?
- I have searched the existing issues and found nothing that matches
Describe the bug
Sending form with js disabled does not work when using useAction hook.
Reproduction steps
- Go to playground https://next-safe-action-playground.vercel.app/stateless-form
- Disable javascript in devtools
- Try sending the form
See attached screenshot of the form element
Expected behavior
Form should be sent with javascript disabled, at least that’s what I understand from looking at the example in the docs https://next-safe-action.dev/docs/recipes/form-actions
Minimal reproduction example
https://next-safe-action-playground.vercel.app/stateless-form
Operating System
macOS
Library version
7.1.3
Next.js version
15.0.0-rc.0
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (6 by maintainers)
@redBaron23 check out
Added a section about progressive enhancement on the website: https://next-safe-action.dev/docs/execution/hooks/usestateaction#progressive-enhancement
@tenghuan123 thank you for your feedback. This issue has also been discussed here:
It would be great to return the
dispatcherfromuseActionStatehook too, and it would also be really simple to implement. The problem, as explained in the discussion, is this:Hey, BTW, do you guys can use the
bindArgsSchemas? I’m new on this so that’s the reason I didn’t open a new issue, and it could be an error on my side. This is the error that I getAs @tenghuan123 said, progressive enhancement is available via
useActionStatehook from React.next-safe-action exports a hook called
useStateActionfrom/stateful-hookspath, but I’ve just tested it and it doesn’t work with JavaScript disabled. Theexecutefunction returned from that hook is a wrapper of the dispatcher from React’suseActionStatehook. This is because otherwise useful props (such as status and client input) couldn’t be returned from the hook — see the image below. *Now I’m actually thinking of changing the
useStateActionAPI to just return the[state, action, isPending]original array or remove the stateful hook entirely from the library and tell users to use the React one. If this will be the case, theuseStateActionhook will be marked as deprecated for a number of minor versions and then removed.What do you think?
*
useStateActionreturn object:Thanks for making it clear. I think it could be a good idea to clearly state it in the docs that if you want progressive enhancement you need to use react native hook.