diff --git a/examples/with-cookie-auth/README.md b/examples/with-cookie-auth/README.md
index a2f9ade600899..68952f384d689 100644
--- a/examples/with-cookie-auth/README.md
+++ b/examples/with-cookie-auth/README.md
@@ -4,3 +4,4 @@ This example has been deprecated and removed in favor of one of the following ex
- [with-cookie-auth-fauna](https://github.com/vercel/next.js/tree/canary/examples/with-cookie-auth-fauna)
- [with-passport](https://github.com/vercel/next.js/tree/canary/examples/with-passport)
- [with-iron-session](https://github.com/vercel/next.js/tree/canary/examples/with-iron-session)
+- [with-next-auth](https://github.com/vercel/next.js/tree/canary/examples/with-next-auth)
diff --git a/examples/with-firebase-authentication/pages/index.js b/examples/with-firebase-authentication/pages/index.js
index 303032df49520..d0067c0cdb218 100644
--- a/examples/with-firebase-authentication/pages/index.js
+++ b/examples/with-firebase-authentication/pages/index.js
@@ -15,7 +15,6 @@ const Index = () => {
user ? ['/api/getFood', user.token] : null,
fetcher
)
-
if (!user) {
return (
<>
@@ -52,7 +51,11 @@ const Index = () => {
{error &&
Failed to fetch food!
}
- {data &&
Your favorite food is {data.food}.
}
+ {data ? (
+
Your favorite food is {data.food}.
+ ) : (
+
Loading...
+ )}
)
}
diff --git a/examples/with-next-auth/.env.development b/examples/with-next-auth/.env.development
new file mode 100644
index 0000000000000..d25c047eea93a
--- /dev/null
+++ b/examples/with-next-auth/.env.development
@@ -0,0 +1 @@
+SITE=http://localhost:3000
diff --git a/examples/with-next-auth/.env.local.example b/examples/with-next-auth/.env.local.example
new file mode 100644
index 0000000000000..303e34e8c2b81
--- /dev/null
+++ b/examples/with-next-auth/.env.local.example
@@ -0,0 +1,11 @@
+GOOGLE_ID=
+GOOGLE_SECRET=
+FACEBOOK_ID=
+FACEBOOK_SECRET=
+TWITTER_ID=
+TWITTER_SECRET=
+GITHUB_ID=
+GITHUB_SECRET=
+EMAIL_SERVER=smtp://username:password@smtp.example.com.com:587
+EMAIL_FROM=NextAuth
+DATABASE_URL=sqlite://localhost/:memory:?synchronize=true
diff --git a/examples/with-next-auth/README.md b/examples/with-next-auth/README.md
new file mode 100644
index 0000000000000..ecbd6f9013f6b
--- /dev/null
+++ b/examples/with-next-auth/README.md
@@ -0,0 +1,50 @@
+# NextAuth.js Example
+
+Next.js example with [`next-auth`](https://github.com/iaincollins/next-auth), an open source, easy to use, and secure by default authentication library.
+
+## How to use
+
+Copy the `.env.local.example` file in this directory to `.env.local` (which will be ignored by Git):
+
+```bash
+cp .env.local.example .env.local
+```
+
+Then, you'll need to fill at least one of the authentication providers by adding the required secrets for it, be that in the form of OAuth keys/secrets from a provider (Google, Twitter, etc.) or an SMTP connection string to enable email authentication.
+
+More details about the providers can be found [here](https://next-auth.js.org/configuration/providers), and for a more complete introduction to `next-auth` check out their [introduction guide](https://next-auth.js.org/getting-started/introduction)
+
+It is vital that you know the deployment URL and define it in the environment file.
+
+### Using `create-next-app`
+
+Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:
+
+```bash
+npx create-next-app --example next-auth with-next-auth-app
+# or
+yarn create next-app --example next-auth with-next-auth-app
+```
+
+### Download manually
+
+Download the example:
+
+```bash
+curl https://codeload.github.com/vercel/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/next-auth
+cd next-auth
+```
+
+Install it and run:
+
+```bash
+npm install
+npm run dev
+# or
+yarn
+yarn dev
+```
+
+Deploy it to the cloud with [Vercel](https://vercel.com/import?filter=next.js&utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
+
+**Note:** For production you need to know in advance the domain (deployment URL) of your application, as it would be required for OAuth to work, once you have it set it to the `VERCEL_URL` environment variable under the settings of your Vercel project.
diff --git a/examples/with-next-auth/components/footer.js b/examples/with-next-auth/components/footer.js
new file mode 100644
index 0000000000000..991b6045f1bb9
--- /dev/null
+++ b/examples/with-next-auth/components/footer.js
@@ -0,0 +1,17 @@
+import styles from './footer.module.css'
+
+const Footer = () => (
+
+ This live demo uses an in-memory database which is automatically erased
+ after ~2 hours. More permanent user databases, etc. can be easily
+ created by defining a db connector your .env file, see{' '}
+ docs
+