Day15 #100DaysOfCode

Signup using Google If simply a user logs in using Google for first time - we also sign him up(record him in our DB) If user selected sign up - we check for already existing record in our DB and create session - else add in records and create session(messages will be empty) If user selected Sign In (first time) - we check if user is not found in DB - we add that user....

June 4, 2022 · 2 min · Anant

Day14 #100DaysOfCode

After signin is implemented and you get session - useSession hook by ’next-auth/react’ gives you session object in react-function-component get the user data from: import { useSession } from "next-auth/react"; export default function Home(props) { const { data: session } = useSession(); if (session) { console.log(`User: -- ${session.user.email}`); Notice the if check on session - Tried to use session without checking if session is not undefined. Got errors - figured it our eventually....

June 4, 2022 · 2 min · Anant

Day13 #100DaysOfCode

Using Nextjs’s built in support for env. variables Next.js has built-in support for loading environment variables from .env.local into process.env. Tried, it worked! Some mistakes I made: I named the file something.env.local - it didnt work - file should be on root with name .env.local. gitignore from nextjs also gives an idea of what this filename should be: # local env files .env*.local Accessing user data (name, email) Using session.user.email...

June 2, 2022 · 1 min · Anant

KK

Beete Lamhe Mithoon Alvida Pritam Aawarapan Banjarapan M. M. Keeravani Aakhon me teri ajab si Vishal-Shekhar O Meri Jaan Pritam Dil Kyu ye mera Tujhe Sochta Hoon Pyar ke Pal and so many more. His renditions have a special place. Very dear and close to heart. One of a kind. KK is immortal - his music will continue to strike emotions to millions of listeners.

June 1, 2022 · 1 min · Anant

Day12 #100DaysOfCode

Add .env file Added env_var.env file at root with following content: GOOGLE_ID= GOOGLE_SECRET= with the values. Also added it to gitignore Install node module dotenv npm install dotenv and in pages\api\auth\[...nextauth].js used at very start, this conditional require: if (process.env.NODE_ENV !== "production") { require("dotenv").config(); } npm run dev - start my next app forgot to do the basic - npm install next-auth restart: Amazing! shows the login button because of change I did in components\layout\MainNavigation....

May 31, 2022 · 2 min · Anant