Next.js w/ Firebase Client-Side
Fill in your credentials to get started
Cloud Firestore Security Rules write permissions are required for adding users
Please press the link below after adding the user
Go to SSR Pageimport { getFirestore, setDoc, doc } from "firebase/firestore"; import Head from "next/head"; import Link from "next/link"; import { useEffect } from "react"; import { useUser } from "../context/userContext"; export default function Home() { // Our custom hook to get context values const { loadingUser, user } = useUser(); const profile = { username: "nextjs_user", message: "Awesome!!" }; useEffect(() => { if (!loadingUser) { // You know that the user is loaded: either logged in or out! console.log(user); } // You also have your firebase app initialized }, [loadingUser, user]); const createUser = async () => { const db = getFirestore(); await setDoc(doc(db, "profile", profile.username), profile); alert("User created!!"); }; return (
Fill in your credentials to get started
Cloud Firestore Security Rules write permissions are required for adding users
Please press the link below after adding the user
Go to SSR Page