Server Action
Unanswered
iC0d3X posted this in #help-forum
iC0d3XOP
Hello guys,
I currently have a server action that creates a class and redirects to a page where all classes are shown :
I wanted to show a toast on the redirected page saying that it has been sucessfully created. As far as I know I cannot use local or session Storage to save the state because is not available on the server.
So i redirected it to the classes page with a search param:
and on the classes page:
But sadly it is really slow, and I dont like the parameter being shown in the url.
Is there maybe any other way to do something like this?
Thanks in advance.
I currently have a server action that creates a class and redirects to a page where all classes are shown :
const scheme = z.object({
name: z.string().nonempty()
});
const {name} = scheme.parse(formData)
//DB INSERT
redirect(process.env.PAGE_URL+"/dashboard/classes");I wanted to show a toast on the redirected page saying that it has been sucessfully created. As far as I know I cannot use local or session Storage to save the state because is not available on the server.
So i redirected it to the classes page with a search param:
redirect(process.env.PAGE_URL+"/dashboard/classes?created=true");and on the classes page:
const toast = useToast();
const router = useRouter()
useEffect(() => {
if (created === 'true') {
toast({
title: "Success",
description: "Class successfully created",
status: "success",
duration: 3000,
isClosable: true,
});
router.replace('/dashboard/classes',{scroll: false})
}
}, [created, router, toast]);But sadly it is really slow, and I dont like the parameter being shown in the url.
Is there maybe any other way to do something like this?
Thanks in advance.
1 Reply
iC0d3XOP
.