"use client"
import { useState } from 'react';
import {auth} from '../../firebase-config'
import {createUserWithEmailAndPassword} from 'firebase/auth'
import { useRouter } from 'next/router';
const SignUp = () => {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const handleSubmit = (e) => {
const router = useRouter();
e.preventDefault();
// Handle form submission here (e.g., send data to server)
createUserWithEmailAndPassword(auth , email,password)
.then(()=>{
setEmail('');
setPassword('');
router.push('/')
}).catch((err)=>{
throw console.log(err);
})
}
I have tried various methods like using useEffect hook and windows.location.href, but I am still facing issues with redirecting the user to the landing page after submission. I even restarted my server, but nothing seems to work as expected.