docs: pull out docs changes from #7443

to minimize the diff there
This commit is contained in:
Balázs Orbán
2023-09-28 01:08:06 +02:00
parent 559842fe02
commit 95eb8aaf69
12 changed files with 269 additions and 243 deletions

View File

@@ -5,7 +5,7 @@ displayed_sidebar: null
## Core team
Without these people, the project could not have become one of the most used authentication library in its category.
Without these people, the project could not have become one of the most used authentication libraries in its category.
- [Balázs Orbán](https://github.com/balazsorban44) - **Lead Maintainer**
- [Thang Vu](https://github.com/ThangHuuVu) - Maintainer (Core)
@@ -14,8 +14,9 @@ Without these people, the project could not have become one of the most used aut
## Special thanks
Special thanks to Lori Karikari for creating most of the original provider configurations to Fredrik Pettersen for creating the original Prisma Adapter, to Gerald Nolan for adding support for Sign in with Apple, and to Jefferson Bledsoe for working on original testing automations.
Special thanks to Filip Skokan for their feedback and high-quality OAuth libraries that we build on, Lori Karikari for creating most of the original provider configurations, Fredrik Pettersen for creating the original Prisma Adapter, Gerald Nolan for adding support for Sign in with Apple, and Jefferson Bledsoe for working on original testing automation.
- [Filip Skokan](https://github.com/panva)
- [Lori Karikari](https://github.com/LoriKarikari)
- [Fredrik Pettersen](https://github.com/Fumler)
- [Gerald Nolan](https://github.com/geraldnolan)
@@ -25,7 +26,7 @@ Special thanks to Lori Karikari for creating most of the original provider confi
Auth.js as it exists today has been possible thanks to the work of many individual contributors.
Thank you to the [dozens of individual contributors](https://github.com/nextauthjs/next-auth/graphs/contributors) who have help shaped Auth.js.
Thank you to the [dozens of individual contributors](https://github.com/nextauthjs/next-auth/graphs/contributors) who have helped shape Auth.js.
## Open Collective
@@ -35,8 +36,10 @@ More information can be found at: https://opencollective.com/nextauth
## History
- Auth.js was originally developed by <a href="https://github.com/iaincollins">Iain Collins</a> in 2016 for Next.js.
- NextAuth.js was originally developed by <a href="https://github.com/iaincollins">Iain Collins</a> in 2016 for Next.js.
- In 2020, Auth.js was rebuilt from the ground up to support Serverless, with support for MySQL, Postgres and MongoDB, JSON Web Tokens and built in support for over a dozen authentication providers.
- In 2020, NextAuth.js was rebuilt from the ground up to support Serverless, with support for MySQL, Postgres and MongoDB, JSON Web Tokens and built-in support for over a dozen authentication providers.
- In 2021, efforts have started to move Auth.js to other frameworks and to support as many databases and providers as possible.
- In 2021, efforts have started to move NextAuth.js to other frameworks and to support as many databases and providers as possible.
- In 2022, Auth.js was born which separated the core authentication logic from the Next.js framework and added support for any new frameworks.

View File

@@ -17,7 +17,7 @@ Continue to our tutorials to see how to use Auth.js for authentication:
- [Setup with magic links](/getting-started/email-tutorial)
- [Integrating with external auth](/getting-started/credentials-tutorial)
### Battery included
### Features
- Built in support for 60+ popular services (Google, Facebook, Auth0, Apple…)
- Built-in email/password-less/magic link

View File

@@ -36,10 +36,6 @@ This tutorial assumes you have a Next.js application set up. If you don't, you c
npm install next-auth
```
:::info
We are working on a new release of `next-auth` that will make it easier to set up Auth.js with Next.js. You can follow the development [on this PR](https://github.com/nextauthjs/next-auth/pull/7443)
:::
### Creating the server config
Create the following [API route](https://nextjs.org/docs/api-routes/dynamic-api-routes#catch-all-api-routes) file. This route contains the necessary configuration for NextAuth.js, as well as the dynamic route handler:
@@ -286,23 +282,24 @@ You can use the `$page.data.session` variable from anywhere on your page. Learn
To protect your API Routes (blocking unauthorized access to resources), you can use `locals.getSessions()` just like in the layouts file to know whether a session exists or not:
```ts title="routes/api/movies/+server.ts"
import { json, error } from "@sveltejs/kit";
import type { RequestEvent } from "./$types";
import { json, error } from "@sveltejs/kit"
import type { RequestEvent } from "./$types"
export async function GET({ locals }: RequestEvent) {
const session = await locals.getSession()
if (!session?.user) {
throw error(401, "You must sign in to view movies.");
throw error(401, "You must sign in to view movies.")
}
return json({
movies: [
{ title: "Alien vs Predator", id: 1 },
{ title: "Reservoir Dogs", id: 2 },
]
],
})
}
```
</TabItem>
<TabItem value="solidstart" label="SolidStart">
TODO: SolidStart
@@ -451,7 +448,6 @@ Great! We're now ready to run our application locally. Start the Svelte app by r
npm run vite dev
```
</TabItem>
<TabItem value="solidstart" label="SolidStart">
TODO SolidStart

View File

@@ -2,19 +2,16 @@
title: Creating a database adapter
---
Using a custom adapter you can connect to any database back-end or even several different databases. Official adapters created and maintained by our community can be found in the [adapters](https://github.com/nextauthjs/next-auth/tree/main/packages) packages. Feel free to add a custom adapter from your project to the repository, or even become a maintainer of a certain adapter. Custom adapters can still be created and used in a project without being added to the repository.
Custom adapters allow you to integrate with any (even multiple) database/back-end service, even if we don't have an [official package](https://github.com/nextauthjs/next-auth/tree/main/packages) available yet. The only requirement is that your database can support the [models](/reference/adapters#models) that Auth.js expects.
## How to create an adapter
For more information about the data these methods need to manage see [models](/reference/adapters#models).
_See the code below for practical example._
_See the code below for a practical example._
### Example code
```ts
/** @return { import("next-auth/adapters").Adapter } */
export default function MyAdapter(client, options = {}) {
import type { Adapter } from '@auth/core/adapters'
export function MyAdapter(client, options = {}): Adapter {
return {
async createUser(user) {
return
@@ -64,7 +61,7 @@ export default function MyAdapter(client, options = {}) {
### Required methods
These methods are required for all sign in flows:
These methods are required for all sign-in flows:
- `createUser`
- `getUser`
@@ -77,7 +74,7 @@ These methods are required for all sign in flows:
- `deleteSession`
- `updateUser`
These methods are required to support email / passwordless sign in:
These methods are required to support email / passwordless sign-in:
- `createVerificationToken`
- `useVerificationToken`
@@ -88,3 +85,8 @@ These methods will be required in a future release, but are not yet invoked:
- `deleteUser`
- `unlinkAccount`
### Useful resources
- [Official adapters' source code](https://github.com/nextauthjs/next-auth/tree/main/packages)
- [`Adapter` interface](/reference/core/adapters#adapter)

View File

@@ -213,3 +213,7 @@ Auth.js / NextAuth.js uses `camelCase` for its database rows while respecting th
## TypeScript
Check out the [`@auth/core/adapters` API Reference](/reference/core/adapters) documentation.
## Create a custom adapter
If you are using a database that we don't have an official adapter for, you can check out the [Creating a database adapter](/guides/adapters/creating-a-database-adapter) guide.

View File

@@ -6,10 +6,11 @@ This section of the documentation contains the API reference for all the officia
## Roadmap
Here are the _state_ of planned and released packages under the `@auth/*` scope. This is not an exhaustive list, but the set of packages that we would like to focus on, to begin with.
Here are the _state_ of planned and released packages under the `@auth/*` and `@next-auth/*` scope, as well as `next-auth`. This is not an exhaustive list, but the set of packages that we would like to focus on, to begin with.
| Feature | Status |
| ---------------------- | -------- |
| `next-auth` | Release (stable). See [docs](https://next-auth.js.org) |
| `@auth/*-adapter` | Released (stable). Fully compatible with `next-auth` and all `@auth/*` libraries. |
| `@next-auth/*-adapter` | Maintenance has stopped. Update to `@auth/*-adapter`. See above. |
| `@auth/core` | Released (experimental). |

View File

@@ -30,14 +30,28 @@ function typedocAdapter(name) {
entryPoints: [`../packages/adapter-${slug}/src/index.ts`],
tsconfig: `../packages/adapter-${slug}/tsconfig.json`,
out: `reference/adapter/${slug}`,
sidebar: {
indexLabel: name,
},
...typedocConfig,
},
]
}
function typedocFramework(pkgDir, entrypoints) {
const id = pkgDir.replace("frameworks-", "")
return [
"docusaurus-plugin-typedoc",
{
...typedocConfig,
id: id,
plugin: [require.resolve("./typedoc-mdn-links")],
watch: process.env.TYPEDOC_WATCH,
entryPoints: entrypoints.map((e) => `../packages/${pkgDir}/src/${e}`),
tsconfig: `../packages/${pkgDir}/tsconfig.json`,
out: `reference/${id === "next-auth" ? "nextjs" : id}`,
skipIndexPage: true,
},
]
}
/** @type {import("@docusaurus/types").Config} */
const docusaurusConfig = {
markdown: {
@@ -245,6 +259,11 @@ const docusaurusConfig = {
},
},
},
async sidebarItemsGenerator({ defaultSidebarItemsGenerator, ...args }) {
const sidebarItems = await defaultSidebarItemsGenerator(args)
const sidebarIdsToOmit = ["reference/core/index", "reference/sveltekit/index", "reference/solidstart/index"]
return sidebarItems.filter((sidebarItem) => !sidebarIdsToOmit.includes(sidebarItem.id))
},
theme: {
customCss: require.resolve("./src/css/index.css"),
},
@@ -252,36 +271,8 @@ const docusaurusConfig = {
],
],
plugins: [
[
"docusaurus-plugin-typedoc",
{
...typedocConfig,
id: "core",
plugin: [require.resolve("./typedoc-mdn-links")],
watch: process.env.TYPEDOC_WATCH,
entryPoints: ["index.ts", "adapters.ts", "errors.ts", "jwt.ts", "types.ts"].map((e) => `${coreSrc}/${e}`).concat(providers),
tsconfig: "../packages/core/tsconfig.json",
out: "reference/core",
sidebar: {
indexLabel: "index",
},
},
],
[
"docusaurus-plugin-typedoc",
{
...typedocConfig,
id: "sveltekit",
plugin: [require.resolve("./typedoc-mdn-links")],
watch: process.env.TYPEDOC_WATCH,
entryPoints: ["index.ts", "client.ts"].map((e) => `../packages/frameworks-sveltekit/src/lib/${e}`),
tsconfig: "../packages/frameworks-sveltekit/tsconfig.json",
out: "reference/sveltekit",
sidebar: {
indexLabel: "index",
},
},
],
typedocFramework("core", ["index.ts", "adapters.ts", "errors.ts", "jwt.ts", "types.ts"]),
typedocFramework("frameworks-sveltekit", ["lib/index.ts", "lib/client.ts"]),
...(process.env.TYPEDOC_SKIP_ADAPTERS
? []
: [

View File

@@ -34,9 +34,9 @@
"@docusaurus/theme-common": "2.4.1",
"@docusaurus/theme-mermaid": "2.4.1",
"@docusaurus/types": "2.4.1",
"docusaurus-plugin-typedoc": "1.0.0-next.5",
"docusaurus-plugin-typedoc": "1.0.0-next.13",
"typedoc": "^0.24.8",
"typedoc-plugin-markdown": "4.0.0-next.6"
"typedoc-plugin-markdown": "4.0.0-next.16"
},
"browserslist": {
"production": [

View File

@@ -3,14 +3,15 @@
"cleanOutputDir": true,
"disableSources": true,
"excludeExternals": true,
"excludeGroups": true,
"excludeInternal": true,
"excludeNotDocumented": true,
"excludePrivate": true,
"excludeProtected": true,
"hideHierarchy": true,
"gitRevision": "main",
"groupByReflections": false,
"hideBreadcrumbs": true,
"hideHierarchy": true,
"hideKindPrefix": true,
"hideGenerator": true,
"kindSortOrder": [
"Function",
@@ -36,8 +37,9 @@
"GetSignature",
"SetSignature"
],
"outputFileStrategy": "modules",
"readme": "none",
"reflectionsWithOwnFile": "none",
"skipErrorChecking": true,
"sort": [
"kind",
"static-first",

View File

@@ -67,6 +67,16 @@
"has": [{ "type": "host", "value": "solid-start.authjs.dev" }],
"destination": "https://authjs.dev/reference/solid-start"
},
{
"source": "/:path(.*)",
"has": [{ "type": "host", "value": "nextjs.authjs.dev" }],
"destination": "https://authjs.dev/reference/nextjs"
},
{
"source": "/v5",
"has": [{ "type": "host", "value": "nextjs.authjs.dev" }],
"destination": "https://authjs.dev/guides/upgrade-to-v5"
},
{
"source": "/:path(.*)",
"has": [{ "type": "host", "value": "errors.authjs.dev" }],

View File

@@ -28,7 +28,7 @@
"@actions/core": "^1.10.0",
"@balazsorban/monorepo-release": "0.1.8",
"@types/jest": "^28.1.3",
"@types/node": "^17.0.25",
"@types/node": "^18.15.11",
"@typescript-eslint/eslint-plugin": "5.47.0",
"@typescript-eslint/parser": "5.47.0",
"eslint": "8.30.0",

371
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff