Skip to content

Commit 8d8121c

Browse files
committed
chore: format
1 parent cb6284b commit 8d8121c

1 file changed

Lines changed: 28 additions & 17 deletions

File tree

docs/elements/guides/30_transient_payloads.mdx

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@ title: Transient Payload passthrough
44
sidebar_label: Transient Payload
55
---
66

7-
Transient payload is an Ory Kratos concept, that allows users of the APIs to pass data through to webhooks. All self-service Kratos flows support transient payloads, and they are passed through to the webhooks as JSON objects. This allows you to use the data in your webhooks, for example to customize the user experience or to trigger specific actions based on the data.
7+
Transient payload is an Ory Kratos concept, that allows users of the APIs to pass data through to webhooks. All self-service
8+
Kratos flows support transient payloads, and they are passed through to the webhooks as JSON objects. This allows you to use the
9+
data in your webhooks, for example to customize the user experience or to trigger specific actions based on the data.
810

9-
Ory Elements allows defining transient payloads on the self-service flow components. To do this, you can use the `transientPayload` prop on the self-service flow components. The value of this prop should be an object that contains the data you want to pass through to the webhooks or a function that returns such an object. The data will be passed through to the webhooks as JSON objects.
11+
Ory Elements allows defining transient payloads on the self-service flow components. To do this, you can use the
12+
`transientPayload` prop on the self-service flow components. The value of this prop should be an object that contains the data you
13+
want to pass through to the webhooks or a function that returns such an object. The data will be passed through to the webhooks as
14+
JSON objects.
1015

16+
- [Read more about webhooks in Ory](../../guides/integrate-with-ory-cloud-through-webhooks.mdx)
1117

1218
## Static Transient Payload
1319

14-
In this example, we define a static transient payload that contains the user's preferred language. This data will be passed through to the webhooks as a JSON object.
20+
In this example, we define a static transient payload that contains the user's preferred language. This data will be passed
21+
through to the webhooks as a JSON object.
1522

1623
```tsx
1724
import { Registration } from "@ory/elements-react/theme"
@@ -37,17 +44,18 @@ export default async function RegistrationPage(props: OryPageParams) {
3744
Card: {},
3845
}}
3946
transientPayload={{
40-
language
47+
language,
4148
}}
4249
/>
4350
)
4451
}
45-
4652
```
4753

4854
## Dynamic Transient Payload
4955

50-
In this example, we define a dynamic transient payload that contains the user's preferred language. The function is called, when the user submits the form, and the API request is made. This allows you to pass dynamic data to the webhooks, based on the user's input or other factors.
56+
In this example, we define a dynamic transient payload that contains the user's preferred language. The function is called, when
57+
the user submits the form, and the API request is made. This allows you to pass dynamic data to the webhooks, based on the user's
58+
input or other factors.
5159

5260
```tsx
5361
"use client"
@@ -57,17 +65,20 @@ import { RegistrationFlow } from "@ory/client-fetch"
5765
import config from "@/ory.config"
5866

5967
export function RegistrationWithPayload({ flow }: { flow: RegistrationFlow }) {
60-
return <Registration
61-
flow={flow}
62-
config={config}
63-
transientPayload={(formValues) => {
64-
const referalCode = localStorage.getItem("referal-code")
65-
return {
66-
referalCode,
67-
}
68-
}}
69-
/>
68+
return (
69+
<Registration
70+
flow={flow}
71+
config={config}
72+
transientPayload={(formValues) => {
73+
const referalCode = localStorage.getItem("referal-code")
74+
return {
75+
referalCode,
76+
}
77+
}}
78+
/>
79+
)
7080
}
7181
```
7282

73-
The function also receives the form values as an argument, which allows you to use the user's input to determine the transient payload. In this example, we are retrieving a referral code from local storage and passing it through to the webhooks.
83+
The function also receives the form values as an argument, which allows you to use the user's input to determine the transient
84+
payload. In this example, we are retrieving a referral code from local storage and passing it through to the webhooks.

0 commit comments

Comments
 (0)