Skip to content
This repository has been archived by the owner on Jul 17, 2022. It is now read-only.

Commit

Permalink
Merge branch 'canary' into sequelize-adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
EXIT-ALAMERY authored Jun 11, 2021
2 parents 9777230 + 4961e43 commit 468bd5e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
10 changes: 5 additions & 5 deletions packages/dynamodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ npm install next-auth @next-auth/dynamodb-adapter@canary

2. Add this adapter to your `pages/api/[...nextauth].js` next-auth configuration object.

You need to pass `aws-sdk` to the adapter in addition to the table name.
You need to pass `DocumentClient` instance from `aws-sdk` to the adapter.
The default table name is `next-auth`, but you can customise that by passing `{ tableName: 'your-table-name' }` as the second parameter in the adapter.

```js
import AWS from "aws-sdk";
Expand All @@ -57,10 +58,9 @@ export default NextAuth({
}),
// ...add more providers here
],
adapter: DynamoDBAdapter({
AWS,
tableName: "next-auth-test",
}),
adapter: DynamoDBAdapter(
new AWS.DynamoDB.DocumentClient()
),
...
});
```
Expand Down
16 changes: 10 additions & 6 deletions packages/pouchdb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Depending on your architecture you can use PouchDB's http adapter to reach any d

## Getting Started

> Prerequesite : Your PouchDB instance MUST provide the `pouchdb-find` plugin since it is used internally by the adapter to build and manage indexes
> **Prerequesite**: Your PouchDB instance MUST provide the `pouchdb-find` plugin since it is used internally by the adapter to build and manage indexes
1. Install `next-auth` and `@next-auth/pouchdb-adapter`

Expand All @@ -37,8 +37,10 @@ import { PouchDBAdapter } from "@next-auth/pouchdb-adapter"
import PouchDB from "pouchdb"

// Setup your PouchDB instance and database
PouchDB.plugin(require("pouchdb-adapter-leveldb")) // or any other adapter
.plugin(require("pouchdb-find")) // /!\ don't forget the pouchdb-find plugin
PouchDB
.plugin(require("pouchdb-adapter-leveldb")) // Or any other PouchDB-compliant adapter
.plugin(require("pouchdb-find")) // Don't forget the `pouchdb-find` plugin

const pouchdb = new PouchDB("auth_db", { adapter: "leveldb" })

// For more information on each option (and a full list of options) go to
Expand All @@ -56,15 +58,17 @@ export default NextAuth({
})
```

## Advanced usage : memory-first caching strategy
## Advanced

### Memory-First Caching Strategy

If you need to boost your authentication layer performance, you may use PouchDB's powerful sync features and various adapters, to build a memory-first caching strategy.

Use an in-memory PouchDB as your main authentication database, and synchronize it with any other persisted PouchDB. You may do a one way, one-off replication at startup from the persisted PouchDB into the in-memory PouchDB, then two-way, continuous, retriable sync.

To go further, see : <https://pouchdb.com/api.html#sync>
This will probably not improve performance much in a serverless environment for various reasons such as concurrency, function startup time increases, etc.

Caveat : this would probably not work in a serverless environment for various reasons (concurrency, serverless function startup time increase, etc.)
For more details, please see https://pouchdb.com/api.html#sync

## Contributing

Expand Down

0 comments on commit 468bd5e

Please sign in to comment.