Skip to content

Commit 2227d34

Browse files
authored
Update documentation (#786)
* Improved homepage and getting started guide * Improved experience viewing docs on mobile devices * Fixed typos
1 parent 9c6ef95 commit 2227d34

File tree

10 files changed

+84
-70
lines changed

10 files changed

+84
-70
lines changed

www/docs/configuration/callbacks.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ The documentation below shows how to implement each callback, their default beha
3838

3939
Use the `signIn()` callback to control if a user is allowed to sign in.
4040

41-
```js title="pages/api/auth/[...nextauth.js]"
41+
```js title="pages/api/auth/[...nextauth].js"
4242
callbacks: {
4343
/**
4444
* @param {object} user User object
@@ -88,7 +88,7 @@ The redirect callback is called anytime the user is redirected to a callback URL
8888

8989
By default only URLs on the same URL as the site are allowed, you can use the redirect callback to customise that behaviour.
9090

91-
```js title="pages/api/auth/[...nextauth.js]"
91+
```js title="pages/api/auth/[...nextauth].js"
9292
callbacks: {
9393
/**
9494
* @param {string} url URL provided as callback URL by the client
@@ -117,7 +117,7 @@ e.g. `getSession()`, `useSession()`, `/api/auth/session`
117117
* When using database sessions, the User object is passed as an argument.
118118
* When using JSON Web Tokens for sessions, the JWT payload is provided instead.
119119

120-
```js title="pages/api/auth/[...nextauth.js]"
120+
```js title="pages/api/auth/[...nextauth].js"
121121
callbacks: {
122122
/**
123123
* @param {object} session Session object
@@ -157,7 +157,7 @@ e.g. `/api/auth/signin`, `getSession()`, `useSession()`, `/api/auth/session`
157157

158158
The contents *user*, *account*, *profile* and *isNewUser* will vary depending on the provider and on if you are using a database or not. If you want to pass data such as User ID, OAuth Access Token, etc. to the browser, you can persist it in the token and use the `session()` callback to return it.
159159

160-
```js title="pages/api/auth/[...nextauth.js]"
160+
```js title="pages/api/auth/[...nextauth].js"
161161
callbacks: {
162162
/**
163163
* @param {object} token Decrypted JSON Web Token

www/docs/configuration/providers.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ id: providers
33
title: Providers
44
---
55

6-
Authentication Providers in NextAuth.js are how you define services can be used to sign in.
6+
Authentication Providers in NextAuth.js are how you define services that can be used to sign in.
77

8-
NextAuth.js is designed to work with any OAuth service, it supports OAuth 1.0, 1.0A and 2.0 and has built-in support for many popular OAuth sign-in services. It also supports email / passwordless authentication.
8+
This includes, OAuth, email / passwordless and other other services.
99

1010
## Sign in with OAuth
1111

12-
### Built-in providers
12+
NextAuth.js is designed to work with any OAuth service, it supports OAuth 1.0, 1.0A and 2.0 and has built-in support for many popular OAuth sign-in services.
13+
14+
### Built-in OAuth providers
1315

1416
* [Apple](/providers/apple)
1517
* [Atlassian](/providers/atlassian)
@@ -20,6 +22,7 @@ NextAuth.js is designed to work with any OAuth service, it supports OAuth 1.0, 1
2022
* [Amazon Cognito](/providers/cognito)
2123
* [Discord](/providers/discord)
2224
* [Facebook](/providers/facebook)
25+
* [FusionAuth](/providers/fusionauth)
2326
* [GitHub](/providers/github)
2427
* [GitLab](/providers/gitlab)
2528
* [Google](/providers/google)
@@ -33,7 +36,7 @@ NextAuth.js is designed to work with any OAuth service, it supports OAuth 1.0, 1
3336
* [Twitter](/providers/twitter)
3437
* [Yandex](/providers/yandex)
3538

36-
### Using a built-in provider
39+
### Using a built-in OAuth provider
3740

3841
1. Register your application at the developer portal of your provider. There are links above to the developer docs for most supported providers with details on how to register your application.
3942

www/docs/getting-started/example.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
---
22
id: example
3-
title: Example
3+
title: Example Code
44
---
55

6-
### Check out the example project
6+
## Get started with NextAuth.js
77

8-
The easiest way to get started is to clone the [example application](https://github.com/iaincollins/next-auth-example) and follow the instructions in the [README](https://github.com/iaincollins/next-auth-example/blob/main/README.md).
8+
The example code below describes to add authentication to a Next.js app.
99

10-
You can find a live demo of the example project at [next-auth-example.now.sh](https://next-auth-example.now.sh)
11-
12-
## Add to an existing project
13-
14-
*The example code below shows how to add authentication to an existing Next.js project.*
10+
:::tip
11+
The easiest way to get started is to clone the [example app](https://github.com/iaincollins/next-auth-example) and follow the instructions in README.md. You can try out a live demo at [next-auth-example.now.sh](https://next-auth-example.now.sh)
12+
:::
1513

1614
### Add API route
1715

1816
To add NextAuth.js to a project create a file called `[...nextauth].js` in `pages/api/auth`.
1917

18+
[Read more about how to add authentication providers.](/configuration/providers)
19+
2020
```javascript title="pages/api/auth/[...nextauth].js"
2121
import NextAuth from 'next-auth'
2222
import Providers from 'next-auth/providers'
@@ -68,13 +68,11 @@ export default function Page() {
6868
}
6969
```
7070

71-
***That's all the code you need to add authentication with NextAuth.js to a project!***
72-
7371
:::tip
7472
You can use the `useSession` hook from anywhere in your application (e.g. in a header component).
7573
:::
7674

77-
### Add to all pages
75+
### Add session state
7876

7977
To allow session state to be shared between pages - which improves performance, reduces network traffic and avoids component state changes while rendering - you can use the NextAuth.js Provider in `pages/_app.js`.
8078

@@ -94,7 +92,7 @@ export default function App ({ Component, pageProps }) {
9492
Check out the [client documentation](/getting-started/client) to see how you can improve the user experience and page performance by using the NextAuth.js client.
9593
:::
9694

97-
### Deploying
95+
### Deploying to production
9896

9997
When deploying your site set the `NEXTAUTH_URL` environment variable to the canonical URL of the website.
10098

@@ -103,5 +101,7 @@ NEXTAUTH_URL=https://example.com
103101
```
104102

105103
:::tip
104+
In production, this needs to be set as an environment variable on the service you use to deploy your app.
105+
106106
To set environment variables on Vercel, you can use the [dashboard](https://vercel.com/dashboard) or the `now env` command.
107107
:::

www/docs/schemas/adapters.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Configure your database by creating the tables and columns to match the schema e
1313

1414
* [MySQL Schema](/schemas/mysql)
1515
* [Postgres Schema](/schemas/postgres)
16+
* [Microsoft SQL Server Schema](/schemas/mssql)
1617

1718
## TypeORM Adapter
1819

www/docusaurus.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ module.exports = {
111111
editUrl: 'https://github.com/iaincollins/next-auth/edit/main/www'
112112
},
113113
theme: {
114-
customCss: require.resolve('./src/css/custom.css')
114+
customCss: require.resolve('./src/css/index.css')
115115
}
116116
}
117117
]

www/package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

www/src/css/custom.css www/src/css/index.css

+37-27
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
--ifm-footer-background-color: #f9f9f9;
2727
--ifm-hero-background-color: #f5f5f5;
2828
--ifm-navbar-background-color: rgba(255,255,255,0.95);
29+
--ifm-h1-font-size: 3rem;
30+
--ifm-h1-font-size: 2rem;
2931
}
3032

3133
html[data-theme='dark']:root {
@@ -124,10 +126,11 @@ a:hover,
124126
.home-subtitle {
125127
justify-content: center;
126128
padding: 0rem 0 2rem 0;
127-
opacity: 0.8;
129+
opacity: 0.6;
128130
font-style: italic;
129-
margin: 0;
131+
margin: 0 auto;
130132
font-size: 1.2rem;
133+
text-align: center;
131134
}
132135

133136
.home-main .code {
@@ -149,6 +152,12 @@ a:hover,
149152
width: 100%;
150153
}
151154

155+
.home-main .code .code-heading span {
156+
opacity: 0.6;
157+
float: right;
158+
font-weight: normal;
159+
}
160+
152161
.home-main .col {
153162
margin-bottom: 1.5rem;
154163
}
@@ -234,31 +243,32 @@ html[data-theme='dark'] {
234243
zoom: .80;
235244
}
236245

237-
/* Targets the 'Documentation' button on mobile */
238-
/* The UX is pretty poor but doing the best we can with it! */
239-
.button.button--secondary.button--sm.menu__button {
240-
position: fixed;
241-
right: 1rem;
242-
bottom: 1rem;
243-
z-index: 1000;
244-
width: auto;
245-
padding: 0.5rem 1rem;
246-
border-radius: 2rem;
247-
border: none;
248-
background: #fff;
249-
box-shadow: 0 0 1rem rgba(0,0,0,0.2);
250-
}
246+
@media screen and (max-width: 996px) {
247+
/* Targets the 'Documentation' button on mobile */
248+
/* The UX is pretty poor but doing the best we can with it! */
249+
.button.button--secondary.button--sm.menu__button {
250+
position: relative;
251+
top: 0;
252+
width: 100%;
253+
background: none;
254+
box-shadow: none;
255+
font-size: 1rem !important;
256+
color: #000;
257+
text-align: left;
258+
padding: .1rem 2rem;
259+
text-decoration: underline;
260+
font-weight: bold;
261+
display: inline;
262+
opacity: 1;
263+
}
251264

252-
html[data-theme='dark'] .button.button--secondary.button--sm.menu__button {
253-
background: #242526;
254-
color: #fff;
255-
box-shadow: 0 0 1rem rgba(0,0,0,0.4);
256-
}
265+
html[data-theme='dark'] .button.button--secondary.button--sm.menu__button {
266+
color: #fff;
267+
}
257268

258-
.button.button--secondary.button--sm.menu__button:before {
259-
font-size: 2rem;
260-
line-height: 2rem;
261-
content: "?";
262-
opacity: 0.8;
263-
display: block;
269+
.button.button--secondary.button--sm.menu__button:before {
270+
content: "Documentation";
271+
opacity: 0.8;
272+
display: block;
273+
}
264274
}

www/src/css/sidebar.css

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* Targets sidebar (left hand side) */
22
.main-wrapper > div > div {
33
border-right: none !important;
4-
background: var(--ifm-footer-background-color);
54
}
65

76
.menu__list .menu__list-item a[href="#!"],
@@ -11,7 +10,7 @@
1110
}
1211

1312
.menu__list .menu__list-item a:not(.menu__link--sublist) {
14-
font-weight: 500;
13+
font-weight: 400;
1514
}
1615

1716
.menu__list .menu__list-item a:not(.menu__link--sublist):hover {
@@ -47,7 +46,9 @@ html[data-theme='dark'] .menu__list .menu__list-item a[href="#!"] {
4746
@media screen and (max-width: 996px) {
4847
.menu.menu--responsive {
4948
top: 3.5rem;
49+
overflow: auto;
5050
padding: 0;
51+
background: var(--ifm-background-color);
5152
}
5253
.navbar {
5354
z-index: 1000 !important;

www/src/pages/index.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import useBaseUrl from '@docusaurus/useBaseUrl'
77
import CodeBlock from '@theme/CodeBlock'
88
import ProviderMarquee from '../components/ProviderMarquee'
99
import Seo from './seo'
10-
import styles from './styles.module.css'
10+
import styles from './index.module.css'
1111

1212
const features = [
1313
{
@@ -149,21 +149,21 @@ function Home () {
149149
</div>
150150
<div className='row'>
151151
<div className='col'>
152-
<h2 className='text--center'>
152+
<h2 className='text--center' style={{ fontSize: '2.5rem' }}>
153153
Add authentication in minutes!
154154
</h2>
155155
</div>
156156
</div>
157157
<div className='row'>
158158
<div className='col col--6'>
159159
<div className='code'>
160-
<h4 className='code-heading'>Server</h4>
160+
<h4 className='code-heading'>Server <span>/pages/api/auth/[...nextauth].js</span></h4>
161161
<CodeBlock className='javascript'>{serverlessFunctionCode}</CodeBlock>
162162
</div>
163163
</div>
164164
<div className='col col--6'>
165165
<div className='code'>
166-
<h4 className='code-heading'>Client</h4>
166+
<h4 className='code-heading'>Client <span>/pages/index.js</span></h4>
167167
<CodeBlock className='javascript'>{reactComponentCode}</CodeBlock>
168168
</div>
169169
</div>
@@ -174,17 +174,16 @@ function Home () {
174174
<Link
175175
to='/getting-started/example'
176176
className='button button--primary button--lg rounded-pill'
177-
>Get Started
177+
>Example Code
178178
</Link>
179179
</p>
180180
</div>
181181
</div>
182182
</div>
183183
</section>
184-
<div className='container'>
185-
<div className='row home-subtitle'>
186-
{siteConfig.title} is not affiliated with Vercel or Next.js
187-
</div>
184+
<div className='home-subtitle'>
185+
<p>NextAuth.js is an open source community project.</p>
186+
<p>NextAuth.js is not affiliated with Vercel or Next.js</p>
188187
</div>
189188
</main>
190189
</div>
@@ -222,7 +221,7 @@ import Providers from 'next-auth/providers'
222221
223222
const options = {
224223
providers: [
225-
// OAuth authentication providers
224+
// OAuth authentication providers...
226225
Providers.Apple({
227226
clientId: process.env.APPLE_ID,
228227
clientSecret: process.env.APPLE_SECRET
@@ -235,13 +234,13 @@ const options = {
235234
clientId: process.env.GOOGLE_ID,
236235
clientSecret: process.env.GOOGLE_SECRET
237236
}),
238-
// Sign in with email
237+
// Passwordless / email sign in
239238
Providers.Email({
240239
server: process.env.MAIL_SERVER,
241240
from: 'NextAuth.js <no-reply@example.com>'
242241
}),
243242
],
244-
// SQL or MongoDB database (or leave empty)
243+
// Optional SQL or MongoDB database to persist users
245244
database: process.env.DATABASE_URL
246245
}
247246

www/src/pages/styles.module.css www/src/pages/index.module.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@
102102
.featureImage {
103103
height: 220px;
104104
width: 220px;
105-
}
105+
}

0 commit comments

Comments
 (0)