diff --git a/README.md b/README.md index 90cfdd8..682f4e3 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file diff --git a/docs/advanced.md b/docs/advanced.md index 8d31c83..18f6d09 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -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 ; + } + + return ; +} +``` \ No newline at end of file diff --git a/docs/contibution.md b/docs/contibution.md new file mode 100644 index 0000000..0e79371 --- /dev/null +++ b/docs/contibution.md @@ -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 +```