You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: authentication-personalization/personalization-setup.mdx
+26-37Lines changed: 26 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,49 +6,23 @@ icon: "user-cog"
6
6
7
7
Personalization customizes your documentation for each user when they are logged in. For example, you can prefill their API keys, show content specific to their plan or role, or hide sections they don't need access to.
8
8
9
-
## Personalized content
9
+
## Personalization features
10
10
11
-
Personalization allows you to customize content with these features.
11
+
Customize content with these personalization capabilities.
12
12
13
13
### API key prefilling
14
14
15
15
Automatically populate API playground fields with user-specific values by returning matching field names in your user data. The field names in your user data must exactly match the names in the API playground for automatic prefilling to work.
16
16
17
17
### Dynamic MDX content
18
18
19
-
Display dynamic content based on user information like name, plan, or organization.
20
-
21
-
The `user` variable contains information sent to your docs from logged in users. See the [User data format](#user-data-format) section below for more information.
22
-
23
-
**Example**: Hello, {user.name??'reader'}!
24
-
25
-
```jsx
26
-
Hello, {user.name??'reader'}!
27
-
```
28
-
29
-
This feature is more powerful when you pair it with custom data about your users. For example, you can give different instructions based on a user's plan.
30
-
31
-
**Example**: Authentication is an enterprise feature. {
32
-
user.org === undefined
33
-
? <>To access this feature, first create an account at the <a href="https://dashboard.mintlify.com/login">Mintlify dashboard</a>.</>
34
-
: user.org.plan !== 'enterprise'
35
-
? <>You are currently on the ${user.org.plan??'free'} plan. See<a href="https://mintlify.com/pricing">our pricing page</a>for information about upgrading.</>
36
-
:<>To request this feature for your enterprise org, contact your admin.</>
37
-
}
19
+
Display dynamic content based on user information like name, plan, or organization using the `user` variable.
38
20
39
21
```jsx
40
-
Authentication is an enterprise feature. {
41
-
user.org === undefined
42
-
? <>To access this feature, first create an account at the <a href="https://dashboard.mintlify.com/login">Mintlify dashboard</a>.</>
43
-
: user.org.plan !== 'enterprise'
44
-
? <>You are currently on the ${user.org.plan??'free'} plan. See<a href="https://mintlify.com/pricing">our pricing page</a>for information about upgrading.</>
45
-
:<>To request this feature for your enterprise org, contact your admin.</>
46
-
}
22
+
Welcome back, {user.firstName}! Your {user.org?.plan} plan includes...
47
23
```
48
24
49
-
<Note>
50
-
The information in `user` is only available for logged in users. For logged out users, the value of `user` will be `{}`. To prevent the page from crashing for logged out users, always use optional chaining on your `user` fields. For example, `{user.org?.plan}`.
51
-
</Note>
25
+
See the [User data format](#user-data-format) section below for detailed examples and implementation guidance.
52
26
53
27
### Page visibility
54
28
@@ -103,7 +77,7 @@ type User = {
103
77
>
104
78
Custom data accessible in your `MDX` content via the `user` variable. Use this for dynamic personalization throughout your documentation.
Welcome back, {user.firstName}! Your {user.plan} plan includes...
114
88
```
115
89
With the example `user` data, this would render as: Welcome back, Ronan! Your Enterprise plan includes...
90
+
91
+
**Advanced conditional rendering**:
92
+
```jsx
93
+
Authentication is an enterprise feature. {
94
+
user.org===undefined
95
+
?<>To access this feature, first create an account at the <a href="https://dashboard.mintlify.com/login">Mintlify dashboard</a>.</>
96
+
:user.org.plan!=='enterprise'
97
+
?<>You are currently on the ${user.org.plan??'free'} plan. See<a href="https://mintlify.com/pricing">our pricing page</a>for information about upgrading.</>
98
+
:<>To request this feature for your enterprise org, contact your admin.</>
99
+
}
100
+
```
101
+
102
+
<Note>
103
+
The information in `user` is only available for logged-in users. For logged-out users, the value of `user` will be `{}`. To prevent the page from crashing for logged out users, always use optional chaining on your `user` fields. For example, `{user.org?.plan}`.
104
+
</Note>
116
105
</ParamField>
117
106
<ParamField
118
107
path="apiPlaygroundInputs"
@@ -167,8 +156,8 @@ Select the handshake method that you want to configure.
167
156
<Tab title="JWT">
168
157
### Prerequisites
169
158
170
-
* A login system that can generate and sign JWTs.
171
-
* A backend service that can create redirect URLs.
159
+
* A login system that can generate and sign JWTs
160
+
* A backend service that can create redirect URLs
172
161
173
162
### Implementation
174
163
@@ -184,7 +173,7 @@ Select the handshake method that you want to configure.
184
173
<Step title="Integrate Mintlify personalization into your login flow.">
185
174
Modify your existing login flow to include these steps after user login:
186
175
187
-
* Create a JWT containing the loggedin user's info in the `User` format. See the [User data format](#user-data-format) section above for more information.
176
+
* Create a JWT containing the logged-in user's info in the `User` format. See the [User data format](#user-data-format) section above for more information.
188
177
* Sign the JWT with the secret key, using the ES256 algorithm.
189
178
* Create a redirect URL back to your docs, including the JWT as the hash.
190
179
</Step>
@@ -238,8 +227,8 @@ To redirect users to specific sections after login, use this URL format: `https:
238
227
</Tab>
239
228
<Tab title="OAuth 2.0">
240
229
### Prerequisites
241
-
* An OAuth server that supports the Auth Code with PKCE Flow.
242
-
* Ability to create an API endpoint accessible by OAuth access tokens.
230
+
* An OAuth server that supports the Auth Code with PKCE Flow
231
+
* Ability to create an API endpoint accessible by OAuth access tokens
0 commit comments