# next-auth-dynamodb-adapter

> DynamoDB adapter for next-auth.

Latest version **1.0.0** (published 2021-02-17) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install next-auth-dynamodb-adapter
pnpm add next-auth-dynamodb-adapter
yarn add next-auth-dynamodb-adapter
bun add next-auth-dynamodb-adapter
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-02-17 |
| First published | 2021-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 36.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Michal Svorc |
| Maintainers | michalsvorc |
| Keywords | dynamodb, next-auth, nextjs, oauth |

## Links

- npm: https://www.npmjs.com/package/next-auth-dynamodb-adapter
- Repository: https://github.com/michalsvorc/next-auth-dynamodb-adapter
- Homepage: https://github.com/michalsvorc/next-auth-dynamodb-adapter#readme
- Issues: https://github.com/michalsvorc/next-auth-dynamodb-adapter/issues
- npm.io page: https://npm.io/package/next-auth-dynamodb-adapter

## Dependencies (2)

- [bcrypt](https://npm.io/package/bcrypt.md) ^5.0.0
- [@aws-sdk/client-dynamodb](https://npm.io/package/@aws-sdk/client-dynamodb.md) ^3.4.1

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2021-02-17

## README

# DynamoDB adapter for [NextAuth.js](https://next-auth.js.org)

## Overview

### Features

- [passwordless email sign in](https://next-auth.js.org/configuration/providers#sign-in-with-email)
- users table: saves user object on successful sign in with any provider
- stateless sessions
- AWS SDK v3 client

### Data persistance

This adapter implements database persistance only for selected [adapter methods](https://next-auth.js.org/tutorials/creating-a-database-adapter#required-methods):
- createUser
- createVerificationRequest
- getVerificationRequest
- deleteVerificationRequest

### Database sessions

Database sessions are not implemented, this adapter relies on usage of JSON Web Tokens for stateless [session management](https://next-auth.js.org/configuration/options#session).

### Notice

This package is not supported by or affiliated with the  project. Visit community supported [NextAuth.js adapters](https://github.com/nextauthjs/adapters) if this adapter does not meet your requirements.

## Installation

### Base package

Install the base [next-auth](https://github.com/nextauthjs/next-auth#getting-started) package.

### Adapter

#### yarn
```console
$ yarn add next-auth-dynamodb-adapter
```

#### npm
```console
$ npm install next-auth-dynamodb-adapter
```

## Usage

```js
import NextAuth from 'next-auth';
import Providers from 'next-auth/providers'
import {DynamoDBAdapter} from 'next-auth-dynamodb-adapter';

export default NextAuth({
  // Configure one or more authentication providers
  providers: [
    // ...add providers here
  ],
  session: {
    // Use JSON Web Tokens for session instead of database sessions.
    jwt: true,
  },
  adapter: new DynamoDBAdapter(
    {
      region: process.env.AWS_REGION,
      credentials: {
        accessKeyId: process.env.AWS_ACCESS_KEY_ID,
        secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
      },
    },
    {
      usersTable: 'Users',
      verificationRequestsTable: 'VerificationRequests',
    }
  ),
  debug: process.env.NODE_ENV !== 'production'
})
```

## Configuration

`DynamoDBAdapter` class instance takes two initialization objects:

```js
new DynamoDBAdapter(DynamoDBClientConfig, TableNameOptions)
```

### DynamoDBClientConfig

DynamoDB client [configuration object](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-dynamodb/globals.html#dynamodbclientconfig).

`Credentials` AWS account must have read/write permissions to tables specified in the `TableNameOptions`.

### TableNameOptions

All properties are optional. Tables must exist before use.

If you do not specify a table name property, the associated authentication data will not be persisted and you don't need to create that table.

#### usersTable

Stores user object after successful sign in.

- `partition key`: id (String)

#### verificationRequestsTable

Stores passwordless email sign in verification requests, one token for one email address at a time.

- `partition key`: email (String)

## Debug option

Turn debug logger off for the production environment as the output might contain user information and verification tokens.

## License

MIT

---
_Source: https://npm.io/package/next-auth-dynamodb-adapter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
