Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/3_bug_adapter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ body:
- "@auth/mongodb-adapter"
- "@auth/neo4j-adapter"
- "@auth/pg-adapter"
- "@auth/postgresjs-adapter"
- "@auth/pouchdb-adapter"
- "@auth/prisma-adapter"
- "@auth/sequelize-adapter"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ on:
- "@auth/mongodb-adapter"
- "@auth/neo4j-adapter"
- "@auth/pg-adapter"
- "@auth/postgresjs-adapter"
- "@auth/pouchdb-adapter"
- "@auth/prisma-adapter"
- "@auth/sequelize-adapter"
Expand Down
1 change: 1 addition & 0 deletions docs/pages/data/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"mongodb": "MongoDB",
"neo4j": "Neo4j",
"pg": "pg",
"postgresjs": "postgresjs",
"pouchdb": "PouchDB",
"sequelize": "Sequelize",
"surrealdb": "SurrealDB",
Expand Down
3 changes: 2 additions & 1 deletion docs/pages/getting-started/adapters/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export default {
mongodb: "MongoDB",
neo4j: "Neo4j",
neon: "Neon",
pg: "PostgreSQL",
pg: "PostgreSQL (pg)",
postgresjs: "Postgres.js",
Copy link
Author

Choose a reason for hiding this comment

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

Could also become:

  • pg and Postgres.js
  • Postgres (pg) and Postgres (Postgres.js)

pouchdb: "PouchDB",
prisma: "Prisma",
sequelize: "Sequelize",
Expand Down
17 changes: 17 additions & 0 deletions docs/public/img/adapters/postgresjs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions packages/adapter-postgresjs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<p align="center">
<br/>
<a href="https://authjs.dev" target="_blank">
<img height="64px" src="https://authjs.dev/img/logo-sm.png" />
</a>
<a href="https://github.com/porsager/postgres" target="_blank">
<img height="64px" src="https://authjs.dev/img/adapters/postgresjs.svg"/>
</a>
<h3 align="center"><b>Postgres.js Adapter</b> - NextAuth.js / Auth.js</a></h3>
<p align="center" style="align: center;">
<a href="https://npm.im/@auth/postgresjs-adapter">
<img src="https://img.shields.io/badge/TypeScript-blue?style=flat-square" alt="TypeScript" />
</a>
<a href="https://npm.im/@auth/postgresjs-adapter">
<img alt="npm" src="https://img.shields.io/npm/v/@auth/postgresjs-adapter?color=green&label=@auth/postgresjs-adapter&style=flat-square">
</a>
<a href="https://www.npmtrends.com/@auth/postgresjs-adapter">
<img src="https://img.shields.io/npm/dm/@auth/postgresjs-adapter?label=%20downloads&style=flat-square" alt="Downloads" />
</a>
<a href="https://github.com/nextauthjs/next-auth/stargazers">
<img src="https://img.shields.io/github/stars/nextauthjs/next-auth?style=flat-square" alt="GitHub Stars" />
</a>
</p>
</p>

---

Check out the documentation at [authjs.dev](https://authjs.dev/reference/adapter/postgresjs).
51 changes: 51 additions & 0 deletions packages/adapter-postgresjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "@auth/postgresjs-adapter",
"version": "1.10.0",
"description": "Postgres.js adapter for next-auth.",
"homepage": "https://authjs.dev",
"repository": "https://github.com/nextauthjs/next-auth",
"bugs": {
"url": "https://github.com/nextauthjs/next-auth/issues"
},
"author": "Guilherme Bassa",
"license": "ISC",
"keywords": [
"next-auth",
"@auth",
"Auth.js",
"next.js",
"oauth",
"postgres",
"postgresjs"
],
"type": "module",
"exports": {
".": {
"types": "./index.d.ts",
"import": "./index.js"
}
},
"files": [
"*.d.ts*",
"*.js",
"src"
],
"private": false,
"publishConfig": {
"access": "public"
},
"scripts": {
"test": "./test/test.sh",
"build": "tsc",
"clean": "rm -rf *.js *.d.ts*"
},
"dependencies": {
"@auth/core": "workspace:*"
},
"devDependencies": {
"postgres": "^3.4.3"
},
"peerDependencies": {
"postgres": "^3"
}
}
49 changes: 49 additions & 0 deletions packages/adapter-postgresjs/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
\set ON_ERROR_STOP true

CREATE TABLE verification_tokens
(
identifier TEXT NOT NULL,
expires TIMESTAMPTZ NOT NULL,
token TEXT NOT NULL,

PRIMARY KEY (identifier, token)
);

CREATE TABLE accounts
(
id UUID DEFAULT gen_random_uuid(),
user_id UUID NOT NULL,
type VARCHAR(255) NOT NULL,
provider VARCHAR(255) NOT NULL,
provider_account_id VARCHAR(255) NOT NULL,
refresh_token TEXT,
access_token TEXT,
expires_at BIGINT,
id_token TEXT,
scope TEXT,
session_state TEXT,
token_type TEXT,

PRIMARY KEY (id)
);

CREATE TABLE sessions
(
id UUID DEFAULT gen_random_uuid(),
user_id UUID NOT NULL,
expires TIMESTAMPTZ NOT NULL,
session_token VARCHAR(255) NOT NULL,

PRIMARY KEY (id)
);

CREATE TABLE users
(
id UUID DEFAULT gen_random_uuid(),
name VARCHAR(255),
email VARCHAR(255) NOT NULL,
email_verified TIMESTAMPTZ,
image TEXT,

PRIMARY KEY (id)
);
Loading