-
-
Notifications
You must be signed in to change notification settings - Fork 303
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
Server Actions example leaks backend code #710
Comments
Oh, yikes, that's, uh, bad. Thank you for the report. Could you make a PR adding a warning to our docs? Something akin to:
As for form factory not being a good primitive to share code, what API would you alternatively propose? Keep in mind that it should/must infer the types of everything properly |
Describe the bug
onServerValidate
is shared between server and browser. Using the example given by the docs:https://tanstack.com/form/latest/docs/framework/react/guides/ssr
Note that it is mentioned that
If
onServerValidate
is only executed in the server, it should not be part of the JS client bundle.Your minimal, reproducible example
https://github.com/benjavicente/tanstack-react-form-actions
Steps to reproduce
Clone the repository, build, start the server, and search for
.age
in JS delivered to the browser.Expected behavior
It doesn't.
How often does this bug happen?
None
Screenshots or Videos
This is part of the JS received by the browser. Search .age<12.
Platform
MacOS.
TanStack Form adapter
react-form
TanStack Form version
0.19.5
TypeScript version
No response
Additional context
I would mark the SSR with Next section in the docs with a warning. Also, the form factory doesn't feel like the right primitive to share code between server and client.
A server only layer could be useful to provide a type-safe way to parse, validate and server validate the form, to then respond with an updated form or another result 🤔
The text was updated successfully, but these errors were encountered: