Router- Server Component: Server Actions, a way to change routes??
Answered
Barbary Lion posted this in #help-forum
Barbary LionOP
In the same way you can useRouter to programmatically change the route, is there a method to do this with server components?
For example a RSC Login page that's using Server Actions to read the form and submit the login logic. Once I've successfully logged on how can I change my route to a dashboard page etc. ?
Is it possible or should I just make the login page a client component?
export default function LoginForm() {
const handleSignIn = async (formData: FormData) => {
"use server";
const email = String(formData.get("email"));
const password = String(formData.get("password"));
const supabase = createServerActionClient<Database>({ cookies });
await supabase.auth.signInWithPassword({
email,
password,
});
revalidatePath("/");
};
return (...
For example a RSC Login page that's using Server Actions to read the form and submit the login logic. Once I've successfully logged on how can I change my route to a dashboard page etc. ?
Is it possible or should I just make the login page a client component?
export default function LoginForm() {
const handleSignIn = async (formData: FormData) => {
"use server";
const email = String(formData.get("email"));
const password = String(formData.get("password"));
const supabase = createServerActionClient<Database>({ cookies });
await supabase.auth.signInWithPassword({
email,
password,
});
revalidatePath("/");
};
return (...