How to integrate in Astrojs project #378
Unanswered
princemuel
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Oh! 🤭 I just noticed the package is specific to Remix Run and React Router. Still I feel like there should be a way to still integrate it |
Beta Was this translation helpful? Give feedback.
0 replies
-
You can use it without Remix or React Router. Conform depends only on the react package at the moment. I am not familiar with Astro. But here is the general idea: export function ExampleForm() {
const [submission, setSubmission] = useState();
const [form, fields] = useForm({
lastSubmission: submission,
async onSubmit(event, { action, method, submission }) {
event.preventDefault();
// Call your action handler
const response = await fetch(action, {
method,
body: JSON.stringify(submission.value),
});
const result = await response.json();
// Assume you are returning `status` and the `submission` object
if (result.status === 'error') {
setSubmission(result.submission);
return;
}
// ... do something else
},
});
// ...
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there 👋 Please, I came across this package recently and tried it out in one of my Remix projects and it was perfect.
I've been having issues though integrating it in my Astrojs project and need help with validating a form (contact form) server-side and passing the errors to the client (No JS Validation).
Thanks
Beta Was this translation helpful? Give feedback.
All reactions