1

I see that {!Route.param} expression can be used to retrieve query parameters within a custom component placed in LWR.

https://developer.salesforce.com/docs/atlas.en-us.exp_cloud_lwr.meta/exp_cloud_lwr/advanced_expressions.htm

But I don't know how to describe this in custom component, so please let me know.

2
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Aug 26, 2022 at 17:47
  • When working with the data binding feature in your LWR site, expressions can be used to retrieve data dynamically. Such as: {!Route.param} to get a parameter value in the URL or {!Site.basePath} to get the base path of your site. Commented Aug 27, 2022 at 11:20

1 Answer 1

1

this is one of the most exciting features of LWR sites. You can use it to pass a URL parameter as an input into any standard or custom component that you are using on your LWR Site. For example if you want to use an'id' url parameter as an input into your custom LWC. You need to expose that parameter using @api in your js file

example @api orderId;

in the meta file you can expose it like below

<targetConfigs>
    <targetConfig targets="lightningCommunity__Default">
        <property name="orderId" type="String" default="{!Route.id}"></property>
    </targetConfig>
</targetConfigs>  

Next you can drag and drop this component in your LWR site. Once this has been done, if anyone navigates to your LWR site using id as an URL parameter (example https://test.my.site.com/lwr/orders?id=00abcdefghik) then the LWC component on that page will automatically get initialised with the provided order id.

Hope this helps

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .