useCustom hook, which allows you to send custom query requests with a specified URL and method.useCustom hook:config object to fit your needs. The method is set to to mimic the behavior of .useCustom does not invalidate queries and therefore will not update the application state. If you need to update the state after the custom create operation, you might need to manually invalidate queries or update the cache.useForm hook will redirect to the "list" page by default. If you want to redirect to a different page, you can use the redirect function to programmatically specify the destination, or set the redirect property in the hook's options.redirect function:redirect property in the useForm hook's options to specify the redirection behavior:resource definition with routes and actions.useForm documentation (https://refine.dev/docs/data/hooks/use-form) and the component documentation (https://refine.dev/docs/core/refine-component).useCreateuseCreateyour-custom-url"post""list"routerProvider<Refine><Refine>import { useCustom, useApiUrl } from "@refinedev/core";
const apiUrl = useApiUrl();
const { data, isLoading } = useCustom({
url: `${apiUrl}/your-custom-url`,
method: "post",
config: {
headers: {
"x-custom-header": "foo-bar",
},
query: {
title: "Foo bar",
},
},
}); const {
refineCore: { onFinish, redirect },
} = useForm();
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
const data = await onFinish(formValues);
redirect("list", data?.data?.id);
}; useForm({ redirect: "list" });