Using Layer’s prebuilt React UI components.
Install Layer components
layerfi/components
package via npm and your preferred package manager.Set up LayerProvider context
LayerProvider
context, which serves as the configuration for fetching data for an individual business. All individual UX components must be rendered within this context.For local testing, you can use your Layer sandbox credentials (APP_ID
and APP_SECRET
).Import component styles
Modify component styles to align with your brand
.layer-container
class.Add components to your pages
Obtain your platform-wide access token
client_id
and client_secret
to obtain a platform-wide access token. See Authentication for more information on this process.
This should be done server-side to avoid exposing your credentials in your client-side application.Retrieve a business-scope access token
business_id
URL parameter. By default, the token’s session duration is set to one hour, but you can customize this by specifying the session_duration
parameter (in seconds) up to 24 hours.Populate access token in LayerProvider context
businessAccessToken
field of the LayerProvider
context: