This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { SessionProvider } from 'next-auth/react' | |
| export default function App ({ | |
| Component, | |
| pageProps: { session, ...pageProps } | |
| }) { | |
| return ( | |
| <SessionProvider session={session}> | |
| <Component {...pageProps} /> | |
| </SessionProvider> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Chane this to your own MongoDB URI. | |
| MONGODB_URI="mongodb://localhost:27017/demo_project" | |
| # in production, change this to the real URL. | |
| NEXTAUTH_URL="http://localhost:3000" | |
| # Random Secret - You can make one with $ openssl rand -base64 32 | |
| SECRET="wXljAz4IWrq1fhojbROM1VmGkLNNKayOxu7kN4Vqnhg=" | |
| # SMTP Example for Gmail |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import NextAuth from 'next-auth' | |
| import { MongoDBAdapter } from '@next-auth/mongodb-adapter' | |
| import EmailProvider from 'next-auth/providers/email' | |
| import MongoClientPromise from '../../../lib/mongodb' | |
| const THIRTY_DAYS = 30 * 24 * 60 * 60 | |
| const THIRTY_MINUTES = 30 * 60 | |
| export default NextAuth({ | |
| secret: process.env.SECRET, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // lib/mongodb.js | |
| import { MongoClient } from 'mongodb' | |
| const uri = process.env.MONGODB_URI | |
| const options = { | |
| useUnifiedTopology: true, | |
| useNewUrlParser: true | |
| } | |
| let client |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MONGODB_URI="mongodb://localhost:27017" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // api/users.js | |
| import dbConnect from '../../lib/dbConnect' | |
| import User from '../../models/User' | |
| export default async function handler (req, res) { | |
| const { method } = req | |
| await dbConnect() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // models/User.js | |
| import mongoose from 'mongoose' | |
| const UserSchema = new mongoose.Schema({ | |
| name: String, | |
| email: String | |
| }) | |
| module.exports = mongoose.models.User || mongoose.model('User', UserSchema) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // /lib/dbConnect.js | |
| import mongoose from 'mongoose' | |
| /** | |
| Source : | |
| https://github.com/vercel/next.js/blob/canary/examples/with-mongodb-mongoose/utils/dbConnect.js | |
| **/ | |
| const MONGODB_URI = process.env.MONGODB_URI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** /connectDB.js **/ | |
| /** | |
| Source : | |
| https://github.com/vercel/next.js/blob/canary/examples/with-mongodb-mongoose/utils/dbConnect.js | |
| **/ | |
| import mongoose from 'mongoose' | |
| const MONGODB_URI = process.env.MONGODB_URI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* ./styles/globals.css */ | |
| @tailwind base; | |
| @tailwind components; | |
| @tailwind utilities; |