Skip to content

Commit

Permalink
Add next.js documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
wparad committed Jan 30, 2024
1 parent c2f9919 commit 423a94e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,4 @@ Curious exactly how these methods work and when they should be used? We have som

## Contributing

### Validating index.d.ts type definitions
For validation it helps to generate and compare the types to the generated files using:
```sh
npx typescript index.js --declaration --allowJs --emitDeclarationOnly --outDir types
```
If you are interested in contributing to the @authress/login SDK, feel fere to read the [contribution.md](./docs/contibution.md) guide.
24 changes: 24 additions & 0 deletions docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,27 @@ Works the same as `authenticate`, but expects to be called as part of the login

### [`openUserConfigurationScreen(options)`](https://github.com/Authress/authress-login.js/blob/release/2.3/src/index.js#L158)
Navigate the user to the profile screen to configure their MFA options. A common usage is `await loginClient.openUserConfigurationScreen({ startPage: UserConfigurationScreen.MFA })


## Next.js recommendations

- See also [Next.js Starter Kit](https://github.com/Authress/nextjs-starter-kit)

Make sure to set `use client` when using the the @authress/login SDK, and make sure to `use server` when using the @authress/sdk. These are specific to login and authorization calls.

For server components, when you would like to check if the user is logged in, the `authorization` cookie is available:


```jsx
import { cookies } from 'next/headers';

export default function Page() {
const cookieStore = cookies();
const userIsLoggedIn = !!cookieStore.has('authorization');
if (userIsLoggedIn) {
return <Page />;
}

return <Unauthorized />;
}
```
7 changes: 7 additions & 0 deletions docs/contibution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Contributions

### Validating index.d.ts type definitions
For validation it helps to generate and compare the types to the generated files using:
```sh
npx typescript index.js --declaration --allowJs --emitDeclarationOnly --outDir types
```

0 comments on commit 423a94e

Please sign in to comment.