/NextJsWithDRFExample

This repository contains the code for a two-part article series that deals with connecting a Django Rest Framework backend with a Next.js + Next-Auth client with Social Authentication. In this example, we use OAuth with Google, but this can be extended to any arbitrary number of Providers.

Primary LanguageTypeScript

Repository Archived

The solution proposed here is currently outdated as of March 15, 2022. Next-Auth.js has had several revisions by now, including a new v4.0 release with a lot of changes to the API and new features. Please follow the updated documentation.

Next.js + NextAuth + Django Rest Framework Social Authentication Example

This repository contains the code for a two-part article series that deals with connecting a Django Rest Framework backend with a Next.js + Next-Auth client with Social Authentication. In this example, we use OAuth with Google, but this can be extended to any arbitrary number of Providers.

The articles:

Part 1.

  • The basics
  • Getting access token

Part 2

  • Using the refresh token to refresh access tokens
  • Pitfalls of useSession() hook and its workaround (as of Apr 30, 2021)
  • Custom HOC to reduce code repetition.

The branches of this repository are named, accordingly, part-1 and part-2. The main branch contains all the changes of both parts merged together into a single, working application.