React components
Learn how to embed Hyperline directly into your React application
Hyperline provides built-in React components to:
- For each customer, display their subscriptions
- preview and update the payment method
- list and download invoices
- list and update billing information
![](https://mintlify.s3-us-west-1.amazonaws.com/hyperline/images/integrations/react4.png)
List and download invoices
![](https://mintlify.s3-us-west-1.amazonaws.com/hyperline/images/integrations/react-payment-method.png)
Display active payment method
This doc assumes that you already have a basic working knowledge of React and that you have already set up a React project.
Getting started
Install the dependency
First install the @hyperline/react-components
NPM package.
npm install @hyperline/react-components
Create an auth token
To allow a customer to see its Hyperline’s data, you need to generate a unique authentication token on your server side. You can use our API and the create auth token endpoint for this.
curl -X POST 'https://api.hyperline.co/v1/integrations/components/token' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <API key>' \ # You can create an [api key here](https://app.hyperline.co/app/settings/api)
-d '{ "customer_id": "<customer ID>" }'
Integrate the React components
Then, integrate the React components. You will most likely generate a new token every time your customer access the page.
import { Subscriptions, PaymentMethod } from "@hyperline/react-components";
export default function HyperlineSubscriptions() {
return (
<Subscriptions
options={{
token: "<YOUR AUTH TOKEN>",
mode: "production" // if you're using our sandbox, set "sandbox" here
}}
/>
);
}
export default function HyperlinePaymentMethod() {
return (
<PaymentMethod
options={{
token: "<YOUR AUTH TOKEN>",
mode: "production" // if you're using our sandbox, set "sandbox" here
}}
onPaymentMethodCreated={() => do something} // optional, from 0.2.20
onPaymentMethodDeleted={() => do something} // optional, from 0.2.20
/>
);
}
![](https://mintlify.s3-us-west-1.amazonaws.com/hyperline/images/integrations/react1.png)
Example of a subscription
![](https://mintlify.s3-us-west-1.amazonaws.com/hyperline/images/integrations/react-update-info.png)
Update billing info
Components
Subscriptions
List all active subscriptions
<Subscriptions
options={{
token: "<token>"
}}
/>
Subscription
Display a subscripton by ID
<Subscription
id="sub_xxxx"
options={{
token: "<token>"
}}
/>
InvoicesList
List and download all invoices and refunds
<InvoicesList
options={{
token: "<token>"
}}
/>
PaymentMethod
Display the current payment method, delete it if allowed, or add a new payment method
<PaymentMethod
options={{
token: "<token>"
}}
/>
CustomerBillingInfoForm
Display a form with all billing info
<CustomerBillingInfoForm
options={{
token: "<token>"
}}
/>
Component options
When using the components, you will need to provide an options
prop with the following parameters:
name | Description | Type | Default value | Required |
---|---|---|---|---|
token | The token specific to your customer | string | ☑️ | |
mode | Which Hyperline environment are you using | production | sandbox | production | |
appearance | Customise the appearance of the component | Object |
Appearance
You can change the colors and fonts of the component.
<Subscriptions
options={{
token: "<token>",
appearance: {
variables: {
borderRadius: "10px",
colorBackground: "#000000",
colorPrimary: "#e1e2f3",
colorPrimaryHover: "#d0d1e5",
colorPrimaryDisabled: "#667",
colorBorder: "#445",
colorText: "#f1f2f3",
colorTextSecondary: "#dededf",
fontFamily: "sacramento"
},
fonts: [
{
src: "url(https://fonts.gstatic.com/s/sacramento/v13/buEzpo6gcdjy0EiZMBUG4C0f_f5Iai0.woff2)",
family: "sacramento"
}
]
}
}}
/>
![](https://mintlify.s3-us-west-1.amazonaws.com/hyperline/images/integrations/react3.png)
Custom color
Variables
They are meant to customise all elements at once.
Variable name | Description |
---|---|
borderRadius | Change the roundness of the elements: Buttons, tables, … |
colorBackground | Most elements have a transparent background. In other cases, you can customise the background color of the element |
colorPrimary | Color used for buttons and accent text |
colorPrimaryHover | Hover color for buttons |
colorPrimaryDisabled | Color of disabled buttons |
colorBorder | The color of all our regular borders |
colorText | Default text color |
colorTextSecondary | Text color of secondary text |
fontFamily | Font used. If you need to import a font, please read the next section |
Fonts
Set your application’s font.
src
Url of the font filefamily
Name of the font - this is the name you’ll use for thefontFamily
variable
<Subscriptions
options={{
fonts: [
{
src: "url(https://fonts.gstatic.com/s/sacramento/v13/buEzpo6gcdjy0EiZMBUG4C0f_f5Iai0.woff2)",
family: "sacramento"
}
]
}}
/>