Skip to content

feat: ✨ add out-of-the-box support for NextAuth.js #1309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Apr 26, 2022

Conversation

ericapisani
Copy link

@ericapisani ericapisani commented Apr 18, 2022

Summary

Adds out of the box support for NextAuth.js by setting the NEXTAUTH_URL to the URL representing the main address of the Netlify site when the next-auth package is detected.

A user will still be required to set the NEXTAUTH_SECRET in production in order to encrypt the NextAuth.js JWT and hash email verification tokens. Related docs

Test plan

  1. Visit the Deploy Preview (here) ...

Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal

Fixes #1242

hedgehog

Standard checks:

  • Check the Deploy Preview's Demo site for your PR's functionality
  • Add docs when necessary

🧪 Once merged, make sure to update the version if needed and that it was published correctly.

@ericapisani ericapisani added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Apr 18, 2022
@ericapisani ericapisani self-assigned this Apr 18, 2022
@netlify
Copy link

netlify bot commented Apr 18, 2022

Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!

Name Link
🔨 Latest commit 592621a
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/62680adcfcb6ac0008379dce
😎 Deploy Preview https://deploy-preview-1309--netlify-plugin-nextjs-nx-monorepo-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Apr 18, 2022

Deploy Preview for netlify-plugin-nextjs-demo ready!

Name Link
🔨 Latest commit 592621a
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/62680adcfcb6ac0008379dc9
😎 Deploy Preview https://deploy-preview-1309--netlify-plugin-nextjs-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Apr 18, 2022

Deploy Preview for netlify-plugin-nextjs-export-demo ready!

Name Link
🔨 Latest commit 592621a
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/62680adc5b291800099c060a
😎 Deploy Preview https://deploy-preview-1309--netlify-plugin-nextjs-export-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Apr 18, 2022

Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!

Name Link
🔨 Latest commit 592621a
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/62680adce9d1ed00084cc721
😎 Deploy Preview https://deploy-preview-1309--netlify-plugin-nextjs-static-root-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@cypress
Copy link

cypress bot commented Apr 18, 2022



Test summary

2 0 0 0


Run details

Project netlify-plugin-nextjs-nx-monorepo-demo
Status Passed
Commit ea84948 ℹ️
Started Apr 26, 2022 3:12 PM
Ended Apr 26, 2022 3:13 PM
Duration 01:11 💡
OS Linux Ubuntu - 20.04
Browser Chrome 100

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@cypress
Copy link

cypress bot commented Apr 18, 2022



Test summary

22 0 0 0


Run details

Project netlify-plugin-nextjs-default-demo
Status Passed
Commit ea84948 ℹ️
Started Apr 26, 2022 3:11 PM
Ended Apr 26, 2022 3:12 PM
Duration 01:25 💡
OS Linux Ubuntu - 20.04
Browser Chrome 100

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@cypress
Copy link

cypress bot commented Apr 18, 2022



Test summary

7 0 0 0


Run details

Project netlify-plugin-nextjs-static-demo
Status Passed
Commit ea84948 ℹ️
Started Apr 26, 2022 3:11 PM
Ended Apr 26, 2022 3:12 PM
Duration 01:21 💡
OS Linux Ubuntu - 20.04
Browser Chrome 100

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@netlify
Copy link

netlify bot commented Apr 19, 2022

Deploy Preview for next-plugin-rsc-demo canceled.

Name Link
🔨 Latest commit 592621a
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-rsc-demo/deploys/62680adcc3b23400095f7cda

@netlify
Copy link

netlify bot commented Apr 19, 2022

Deploy Preview for next-plugin-edge-middleware canceled.

Name Link
🔨 Latest commit 592621a
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/62680adc42a24e0009d3c1a6

export const isNextAuthInstalled = (): boolean => {
try {
// eslint-disable-next-line import/no-unassigned-import, node/no-extraneous-require, import/no-extraneous-dependencies
require('next-auth')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach follows what's suggested in the npm documentation around optional dependencies

@ericapisani ericapisani marked this pull request as ready for review April 20, 2022 17:12
@ericapisani ericapisani requested a review from a team April 20, 2022 17:13
Copy the .env.local.example file in this directory to .env.local (which will be ignored by Git):

```
cp .env.local.example .env.local

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[dust] We could improve the DX by running cp .env.local.example .env.local as part of a postinstall action, checking if one exists already before overwriting it. This also relates to our discussion on Slack about setting up some env vars postinstall.

@ascorbic
Copy link
Contributor

This looks great! Can we get the demo site setup to build for PRs? I'd say this is a boulder unless there's a good reason not to

@netlify
Copy link

netlify bot commented Apr 25, 2022

👷 Deploy Preview for bright-unicorn-4dffab processing.

Name Link
🔨 Latest commit 99dfc1d
🔍 Latest deploy log https://app.netlify.com/sites/bright-unicorn-4dffab/deploys/6266e46b6cbca90008d3a242

mainly done to trigger a deploy preview build and that it works as expected
@netlify
Copy link

netlify bot commented Apr 25, 2022

Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!

Name Link
🔨 Latest commit 592621a
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/62680adc1fdd2c00093edf41
😎 Deploy Preview https://deploy-preview-1309--netlify-plugin-nextjs-next-auth-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Copy link
Contributor

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@ericapisani ericapisani merged commit 45c0978 into main Apr 26, 2022
@ericapisani ericapisani deleted the ep/next-auth-support branch April 26, 2022 15:18
Copy link

@nickytonline nickytonline left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the changes @ericapisani! Let's go! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support NextAuth out of the box
3 participants