Lightning App - getting URL parameter

  • We are planning to convert some of our VF pages to Lightning apps. Some our VF pages, particularly surveys are URL parameter-driven, since we send survey links directly to users, i.e. https://[vf_instance]

    Say we convert the VF page to an Lightning app, we would probably be sending the Lightning survey like this https://[vf_instance]


    In VF page controller, PageReference.getParameters() contains the much needed caseid

    However, in Lightning component controller, PageReference.getParameters() does not contain any URL parameters.

    How can I get the URL parameter in Lightning app/component apex controller?


  • In lightning whatever attribute you define can be passed as a query parameter .

    Lets take a look with sample example

      <aura:attribute name="whom" type="String" default="world"/>
       Hello {!v.whom}!

    Here is how the result will look like

    enter image description here

    Now I will add a query parameter with value as per my attribute defined whom in the URL and now the result will be as below

    enter image description here

    In very simple terms you just need to define an aura:attribute and you are good

     <aura:attribute name="caseid" type="String"/>

    Good explanation @Mohith . Just an addition, it only supports String type of attributes :)

    This will only work is the attribute is defined in the .app. What is I want to pass the parameter to a nested component?

    Does it alos work with embedded components in custom lightning page in COmmunity?

    Thanks @AllenMann for tip that the `` must be defined in the app containing your component. To pass the parameter to any nested components then set them as attribute values on the nested components like `` where your containing app declares `` per @Mohith's example

    Is this documented anywhere? It works but I am a bit weirded out that I hadn't seen any information anywhere about it.

License under CC-BY-SA with attribution

Content dated before 7/24/2021 11:53 AM