|
| 1 | +--- |
| 2 | +title: 'Overview' |
| 3 | +description: 'Give your users a personalized docs experience' |
| 4 | +--- |
| 5 | + |
| 6 | +Sometimes, when writing docs, you wish you knew just a little bit about the person reading them. Maybe you only want to show them the information they should care about. Maybe you want to craft examples that they can use out-of-the-box. |
| 7 | + |
| 8 | +With Mintlify, you can add User Auth to identify your users and tailor your docs content to them. |
| 9 | + |
| 10 | +## What is User Auth |
| 11 | + |
| 12 | +User Auth allows you to configure a method for identifying and authenticating your users. Once authenticated, you can share user-specific information that can be used to personalize the docs. This unlocks some powerful features: |
| 13 | + |
| 14 | +1. **Customize MDX content** with a user's information, such as their name, plan, or title. |
| 15 | +2. **Prefill API keys** in the API Playground for streamlined use. |
| 16 | +3. <b className="text-primary">(Coming soon!)</b> **Selectively show pages** in the navigation based on a user's groups. |
| 17 | + |
| 18 | +## What *isn't* User Auth |
| 19 | + |
| 20 | +At this time, User Auth cannot provide any of the following: |
| 21 | + |
| 22 | +1. **Private docs content.** While you can hide pages from unauthenticated users, those pages are still accessible by anyone who can guess the URL. If your documentation contains sensitive information, User Auth is not enough to hide it. |
| 23 | +2. **A Mintlify-backed user database.** Mintlify does not store *any* information about your users. Rather, it relies on your existing infrastructure to serve as the source-of-truth for user data. |
| 24 | + |
| 25 | +< Note>If you are interested in private docs content, [contact our team ]([email protected]) to explore solutions.</ Note> |
| 26 | + |
| 27 | +## How to Use |
| 28 | + |
| 29 | +### Customizing MDX Content |
| 30 | + |
| 31 | +When writing content, you can use the `userContext` variable to access the information you have sent to your docs. Here's a real world example: |
| 32 | + |
| 33 | +User Auth is an enterprise feature. { |
| 34 | + userContext.org === undefined |
| 35 | + ? <>To access this feature, first create an account at the <a href="https://dashboard.mintlify.com/login">Mintlify dashboard</a>.</> |
| 36 | + : userContext.org.plan !== 'enterprise' |
| 37 | + ? <>You are currently on the ${userContext.org.plan ?? 'free'} plan. To upgrade, navigate to the <a href="https://dashboard.mintlify.com/settings/billing">billing page</a> in the Mintlify dashboard.</> |
| 38 | + : <>As an enterprise organization, you can enable this feature right now from your <a href="https://dashboard.mintlify.com/settings/integrations">Mintlify dashboard settings</a></> |
| 39 | +} |
| 40 | + |
| 41 | +```jsx |
| 42 | +User Auth is an enterprise feature. { |
| 43 | + userContext.org === undefined |
| 44 | + ? <>To access this feature, first create an account at the <a href="https://dashboard.mintlify.com/login">Mintlify dashboard</a>.</> |
| 45 | + : userContext.org.plan !== 'enterprise' |
| 46 | + ? <>You are currently on the ${userContext.org.plan ?? 'free'} plan. To upgrade, navigate to the <a href="https://dashboard.mintlify.com/settings/billing">billing page</a> in the Mintlify dashboard.</> |
| 47 | + : <>As an enterprise organization, you can enable this feature right now from your <a href="https://dashboard.mintlify.com/settings/integrations">Mintlify dashboard settings</a></> |
| 48 | +} |
| 49 | +``` |
| 50 | +
|
| 51 | +<Note> |
| 52 | + The information in `userContext` is only available after a user has logged in. For logged out users, the value of `userContext` will be `{}`. To prevent the page from crashing for logged-out users, always use optional chaining on your `userContext` fields, e.g. `{userContext.org?.plan}` |
| 53 | +</Note> |
| 54 | +
|
| 55 | +### Prefilling API Keys |
| 56 | +
|
| 57 | +If you return API Playground inputs in the user info, they will automatically be prefilled in the API Playground. Make sure the name of the field in the user info is an exact match of the name in the API Playground. |
| 58 | +{/* |
| 59 | +### Showing/Hiding Pages |
| 60 | +
|
| 61 | +By default, every page is visible to every user. If you want to restrict which pages are visible to your users, you can add a `groups` field in your page metadata. |
| 62 | +When determining which pages to show to the user, Mintlify will check which groups the user belongs to. |
| 63 | +If the user is not in any of the groups listed in the page metadata, the page will not be shown. |
| 64 | +
|
| 65 | +```md |
| 66 | +--- |
| 67 | +title: 'Managing Your Users' |
| 68 | +description: 'Adding and removing users from your organization' |
| 69 | +groups: ['admin'] |
| 70 | +--- |
| 71 | +``` |
| 72 | +
|
| 73 | +Here's a table that displays whether a page is shown for different combinations of `groups` in UserInfo and page metadata: |
| 74 | +
|
| 75 | +| | `groups` not in UserInfo | `groups: []` in UserInfo | `groups: ['admin']` in UserInfo | |
| 76 | +|:-----------------------------------|:------------------------:|:-------------------------:|:--------------------------------:| |
| 77 | +| `groups` not in metadata | ✅ | ✅ | ✅ | |
| 78 | +| `groups: []` in metadata | ❌ | ❌ | ❌ | |
| 79 | +| `groups: ['admin']` in metadata | ❌ | ❌ | ✅ | |
| 80 | +
|
| 81 | +<Note>Note that an empty array in the page metadata is interpreted as "No groups should see this page."</Note> */} |
0 commit comments