Edit in GitHubLog an issue

Venia targets

This page lists the Targets declared in the Venia UI package.

Accessing the targets#

Access these in your intercept files by calling targets.of('@magento/venia-ui') on the TargetProvider object.

Copied to your clipboard
1/* my-custom-interceptors.js */
2
3module.exports = (targets) => {
4 const veniaTargets = targets.of("@magento/venia-ui");
5};

See the PWA Studio Target Experiments project repository for documented examples of extensions that use PWA Studio's extensibility framework.

Members

richContentRenderers : tapable.SyncHook

Provides access to the list of rendering strategies used by the RichContent component.

This target collects a list of RichContentRenderer modules. It builds an array of these renderers, which Venia's RichContent component uses to try and render a block of "rich" content, such as HTML.

Use this target if your backend system uses a customized content storage format instead of plain HTML in "rich content" fields such as product descriptions and CMS blocks.

routes : tapable.AsyncSeriesWaterfall

Provides access to Venia's routing table.

This target lets you add new routes to your storefronts. You can also modify Venia's existing client-side routes, such as cart or checkout URLs.

NOTE: This target does not include routes controlled by the Magento admin, such as CMS or catalog URLs.

checkoutPagePaymentTypes : tapable.SyncHook

Provides access to Venia's checkout page payment methods

This target lets you add new checkout page payment to your storefronts.

savedPaymentTypes : tapable.SyncHook

Provides access to Venia's saved payment methods

This target lets you add new saved payment method to your storefronts.

editablePaymentTypes : tapable.SyncHook

Provides access to Venia's editable payment methods

This target lets you add new editable payment method to your storefronts.

summaryPagePaymentTypes : tapable.SyncHook

Provides access to Venia's summary page for a payment method.

This target allows you to add custom payment summary rendering for the summary page in the checkout.

Typedefs

rendererInterceptFunction : function

Intercept function signature for the richContentRenderers target.

Interceptors of richContentRenderers should call .add on the provided renderer list.

routesInterceptFunctionArray.<RouteDefinition>

Intercept function signature for the routes target.

Interceptors of routes receive an array of RouteDefinition objects, which Venia will use to either generate a custom <AuthRoute /> component or a React Router <Route /> component in the final bundle based on the authed prop.

The AuthRoute will either return a React Router <Route /> component or a <Redirect /> component depending if the user is signed in and if the route needs authentication or not.

Interceptors must return an array of RouteDefinitions, either by mutating and then returning the array they received, or by returning a new array of RouteDefinitions.

RouteDefinition : Object

A route definition object that describes a route in your storefront.

paymentInterceptFunction : function

Intercept function signature for the checkoutPagePaymentTypes target.

Interceptors of checkoutPagePaymentTypes should call .add on the provided payment list.

CheckoutPaymentDefinition : Object

A payment definition object that describes a checkout page payment in your storefront.

savedPaymentInterceptFunction : function

Intercept function signature for the savedPaymentTypes target.

Interceptors of savedPaymentTypes should call .add on the provided payment list.

SavedPaymentDefinition : Object

A payment definition object that describes a saved payment in your storefront.

editablePaymentInterceptFunction : function

Intercept function signature for the editablePaymentTypes target.

Interceptors of editablePaymentTypes should call .add on the provided payment list.

EditablePaymentDefinition : Object

A payment definition object that describes a saved payment in your storefront.

rootShimmerInterceptFunction : function

Intercept function signature for the rootShimmerTypes target.

Interceptors of rootShimmerTypes should call .add on the provided shimmer list.

RootShimmerTypesDefinition : Object

A root component shimmer object that can be used during page transitions on your storefront

Interfaces

RichContentRenderer : Object

Rich content renderers for the RichContent component must implement this interface. Should be written as an ES Module—a module that exports functions with these names, rather than an object with these functions as properties.

Rich content renderers for the RichContent component must implement this interface. Should be written as an ES Module—a module that exports functions with these names, rather than an object with these functions as properties.

Properties

NameTypeDescription
ComponentReact.ComponentThe React component that does the actual rendering. It will receive the props passed to the RichContent object, including html.
canRenderfunctionFunction that receives the content to be rendered as a string, and should return true if the Component can understand and render that content.

Example (A renderer that can render any content containing the string "honk")

Copied to your clipboard
1import React from 'react';
2import PlainHtmlRenderer from '@magento/venia-ui/components/richContent/plainHtmlRenderer';
3
4function GooseRenderer(props) {
5 const html = props.html.replace(/honk/gim, '<strong>HONK!🦢</strong>');
6 return <PlainHtmlRenderer html={html} />;
7}
8export const Component = GooseRenderer;
9
10export function canRender(content) {
11 return /honk/gim.test(content);
12}

Provides access to the list of rendering strategies used by the RichContent component.

This target collects a list of RichContentRenderer modules. It builds an array of these renderers, which Venia's RichContent component uses to try and render a block of "rich" content, such as HTML.

Use this target if your backend system uses a customized content storage format instead of plain HTML in "rich content" fields such as product descriptions and CMS blocks.

See

Example (Add a renderer)

Copied to your clipboard
1targets.of('@magento/venia-ui').richContentRenderers.tap(
2 renderers => renderers.add({
3 componentName: 'AdobeXM',
4 importPath: '@adobe/xm-components/xm-renderer'
5 })
6);

Provides access to Venia's routing table.

This target lets you add new routes to your storefronts. You can also modify Venia's existing client-side routes, such as cart or checkout URLs.

NOTE: This target does not include routes controlled by the Magento admin, such as CMS or catalog URLs.

See

Example (Add a custom route for a blog module)

Copied to your clipboard
1const veniaTargets = targets.of('@magento/venia-ui')
2const routes = veniaTargets.routes
3routes.tap(
4 routesArray => {
5 routesArray.push({
6 name: 'Blog',
7 pattern: '/blog/:slug/:id',
8 path: '@partner/pwa-studio-blog'
9 });
10 return routesArray;
11 })

Provides access to Venia's checkout page payment methods

This target lets you add new checkout page payment to your storefronts.

See

Example (Add a payment)

Copied to your clipboard
1targets.of('@magento/venia-ui').checkoutPagePaymentTypes.tap(
2 checkoutPagePaymentTypes => checkoutPagePaymentTypes.add({
3 paymentCode: 'braintree',
4 importPath: '@magento/braintree_payment'
5 })
6);

Provides access to Venia's saved payment methods

This target lets you add new saved payment method to your storefronts.

See

Example (Add a payment)

Copied to your clipboard
1targets.of('@magento/venia-ui').savedPaymentTypes.tap(
2 savedPaymentTypes => savedPaymentTypes.add({
3 paymentCode: 'braintree',
4 importPath: '@magento/braintree_payment'
5 })
6);

Provides access to Venia's editable payment methods

This target lets you add new editable payment method to your storefronts.

See

Example (Add a payment)

Copied to your clipboard
1targets.of('@magento/venia-ui').editablePaymentTypes.tap(
2 editablePaymentTypes => editablePaymentTypes.add({
3 paymentCode: 'braintree',
4 importPath: '@magento/braintree_payment'
5 })
6);

Provides access to Venia's summary page for a payment method.

This target allows you to add custom payment summary rendering for the summary page in the checkout.

See

Example (Add a payment)

Copied to your clipboard
1targets.of('@magento/venia-ui').editablePaymentTypes.tap(
2 editablePaymentTypes => editablePaymentTypes.add({
3 paymentCode: 'braintree',
4 importPath: '@magento/braintree_payment'
5 })
6);

Intercept function signature for the richContentRenderers target.

Interceptors of richContentRenderers should call .add on the provided renderer list.

Parameters

NameTypeDescription
renderersRichContentRendererListThe list of renderers registered so far in the build.

Intercept function signature for the routes target.

Interceptors of routes receive an array of RouteDefinition objects, which Venia will use to either generate a custom <AuthRoute /> component or a React Router <Route /> component in the final bundle based on the authed prop.

The AuthRoute will either return a React Router <Route /> component or a <Redirect /> component depending if the user is signed in and if the route needs authentication or not.

Interceptors must return an array of RouteDefinitions, either by mutating and then returning the array they received, or by returning a new array of RouteDefinitions.

Returns: Array.<RouteDefinition> — Your function must return the modified array, or a new array you have constructed

Parameters

NameTypeDescription
routesArray.<RouteDefinition>Array of registered routes

Example

Copied to your clipboard
1const intercept = routesArray => {
2 return [
3 { name: 'Backstop', pattern: '*', path: '@my-components/backstop' },
4 ...routesArray
5 ]
6}

A route definition object that describes a route in your storefront.

Properties

NameTypeDescription
namestringFriendly name for the React component
pathstringResolvable path to the component the Route component will render
patternstringRoute pattern. This is used as the path prop for the <Route/> component.
[exact]booleanTells the router whether it should match the route exactly or not. This property is optional.
[authed]booleanUses the custom AuthRoute component if the user needs to be signed in to access the route. This property is optional.
[redirectTo]stringUrl will be the redirection url when user are not signed in and are trying to access an authed route. This property is optional. Default is "/".

Example (A custom route with a URL parameter)

Copied to your clipboard
1const myCustomRoute = {
2 name: 'MyRoute',
3 pattern: '/my-route/:myRouteParam',
4 path: '@my-components/my-route-component'
5}

Intercept function signature for the checkoutPagePaymentTypes target.

Interceptors of checkoutPagePaymentTypes should call .add on the provided payment list.

Parameters

NameTypeDescription
renderersCheckoutPaymentTypesDefinitionThe list of payments registered so far in the build.

A payment definition object that describes a checkout page payment in your storefront.

Properties

NameTypeDescription
paymentCodestringis use to map your payment
importPathstringResolvable path to the component the Route component will render

Example (A custom payment method)

Copied to your clipboard
1const myCustomPayment = {
2 paymentCode: 'cc',
3 importPath: '@partner/module/path_to_your_component'
4}

Intercept function signature for the savedPaymentTypes target.

Interceptors of savedPaymentTypes should call .add on the provided payment list.

Parameters

NameTypeDescription
renderersSavedPaymentTypesDefinitionThe list of saved payments registered so far in the build.

A payment definition object that describes a saved payment in your storefront.

Properties

NameTypeDescription
paymentCodestringis use to map your payment
importPathstringResolvable path to the component the Route component will render

Example (A custom payment method)

Copied to your clipboard
1const myCustomPayment = {
2 paymentCode: 'cc',
3 importPath: '@partner/module/path_to_your_component'
4}

Intercept function signature for the editablePaymentTypes target.

Interceptors of editablePaymentTypes should call .add on the provided payment list.

Parameters

NameTypeDescription
renderersEditablePaymentTypesDefinitionso far in the build.

A payment definition object that describes a saved payment in your storefront.

Properties

NameTypeDescription
paymentCodestringis use to map your payment
importPathstringResolvable path to the component the Route component will render

Example (A custom payment method)

Copied to your clipboard
1const myCustomPayment = {
2 paymentCode: 'cc',
3 importPath: '@partner/module/path_to_your_component'
4}

Intercept function signature for the rootShimmerTypes target.

Interceptors of rootShimmerTypes should call .add on the provided shimmer list.

Parameters

NameTypeDescription
shimmersRootShimmerTypesDefinitionso far in the build.

A root component shimmer object that can be used during page transitions on your storefront

Properties

NameTypeDescription
shimmerTypestringis use to map your page type to the component
importPathstringResolvable path to the component the Shimmer component will render

Example (A CMS Page Shimmer)

Copied to your clipboard
1const cmsShimmer = {
2 shimmerType: 'CMS_PAGE_SHIMMER',
3 importPath: '@partner/module/path_to_your_component'
4}

Source Code: pwa-studio/packages/venia-ui/lib/targets/venia-ui-declare.js

Implementation of our 'richContentRenderers' target. This will gather RichContentRenderer declarations { importPath, componentName } from all interceptors, and then tap builtins.transformModules to inject a module transform into the build which is configured to generate an array of modules to be imported and then exported.

An instance of this class is made available when you use VeniaUI's richContentRenderers target.

Add a rendering strategy to the RichContent component.

Parameters

NameTypeDescription
strategyObjectDescribes the rich content renderer to include
strategy.importPathstringImport path to the RichContentRenderer module. Should be package-absolute.
strategy.componentNamestringName that will be given to the imported renderer in generated code. This is used for debugging purposes.

Source Code: pwa-studio/packages/venia-ui/lib/targets/RichContentRendererList.js

  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.