Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@next-auth/dynamodb-adapter

Package Overview
Dependencies
Maintainers
4
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@next-auth/dynamodb-adapter

AWS DynamoDB adapter for next-auth.

  • 0.3.1-pr.90.152
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5K
decreased by-25.82%
Maintainers
4
Weekly downloads
 
Created
Source

AWS DynamoDB Adapter

AWS Dynamodb + NextAuth.js

Initial Setup

You need a table with as partition key pk and as sort key sk. Your table also need a global secondary index names GSI1 with GSI1PK as partition key and GSI1SK as sorting key. You can set whatever you want as the table name and the billing method.

Config

You need to pass aws-sdk to the adapter in addition to the tablename.

// /pages/api/auth/[...nextauth].js

import AWS from "aws-sdk";
import NextAuth from "next-auth";
import Providers from "next-auth/providers";
import { DynamoDBAdapter } from "@next-auth/dynamodb-adapter"

AWS.config.update({
  accessKeyId: process.env.NEXT_AUTH_AWS_ACCESS_KEY,
  secretAccessKey: process.env.NEXT_AUTH_AWS_SECRET_KEY,
  region: process.env.NEXT_AUTH_AWS_REGION,
});

export default NextAuth({
  // Configure one or more authentication providers
  providers: [
    Providers.GitHub({
      clientId: process.env.GITHUB_ID,
      clientSecret: process.env.GITHUB_SECRET,
    }),
    Providers.Email({
      server: process.env.EMAIL_SERVER,
      from: process.env.EMAIL_FROM,
    }),
    // ...add more providers here
  ],
  adapter: DynamoDBAdapter({
    AWS,
    tableName: "next-auth-test",
  }),
  ...
});

(AWS secrets start with NEXT_AUTH_ in order to not conflict with Vercel's reserved environment variables.)

Table structure

The table respect the single table strucuture. This has many advantages :

  • Only one table to manage, monitor and provisioned
  • Querying relation is faster than with multi table schema (if you want to retreive all sessions from an user for example)
  • Only one table need to be replicated if you want to be multi-regions

Here is a schema of the table :

Table schema

Keywords

FAQs

Package last updated on 16 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc