$npx create-next-app@latest
$npm run dev
$npm install next-auth
$npm install mongoose
$npm install dotenv
$npm install bcrypt
$npm install @auth/mongodb-adapter mongodb
1. Google console cloud
2. Create project
3. OAuth consent screen
# use domain name in production
http://localhost:3000/api/auth/callback/google
// https://github.com/dejwid/food-ordering/blob/master/tsconfig.json
// Add in tsconfig.json
"paths":{
"@/*":["./src/*"]
},
http://localhost/register
fetch('/api/register', {});
// Project-Folder/.env
MONGO_URL='mongodb://127.0.0.1:27017/pizza-shop'
button {
@apply block w-full text-gray-700 font-semibold;
}
// AppContext.js (Composition)
export default function AppProvider({children}){
<SessionProvider>{children}</SessionProvider>
}
// layout.js
// import { AppProvider } from 'AppContext.js'
<AppProvider>
<main></main>
</AppProvider>
next.config.mjs
// used in: app/profile/page.js
// @type {import('next').NextConfig}
const nextConfig = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'lh3.googleusercontent.com'
},
],
},
};
export default nextConfig;
1. NEXTAUTH_SECRET="thisissecrete"
2. use in [...nextauth]/routes.js
use await
await getServerSession(authOptions)
Check schema attributes if complete. 'name':'', 'email':'', etc..
https://youtu.be/nGoSP3MBV2E?si=HDFaC_yNUEorF2iz&t=13457
$npm install @aws-sdk/client-s3
$npm install uniqid
$npm install react-hot-toast
// layout.js
// https://medium.com/@morerahul620/react-hot-toast-setup-in-next-js-bbf2b5d91c63
import { Toaster } from "react-hot-toast";
<Toaster position="top-center" />
// by default components are Server side componets
// add "use client"; above the file to allow client side rendering
"use client";
import React from "react";
app-index.js:31 Warning: Extra attributes from the server: data-new-gr-c-s-check-loaded,data-gr-ext-installed
Disable Grammarly chrome extension and ColorZilla
screen.js:1 Uncaught TypeError: Cannot read properties of null (reading 'getContext')
Unable to commit NextJs project folder in Github
Manually copy the files and folders to a new folder leaving, hidden files.