+ Start a Discussion
Flint LockwoodFlint Lockwood 

Redirect to Lightning Component from Visualforce page

Is there a way to redirect to a Lighting Component from a Visualforce Page and pass in attribute values?
Shun KosakaShun Kosaka
I think there are two ways.
1) Use Lightning Application - Lightning Component cannot have an unique URL but Lightning Application can. So you wrap the component in lightning application and receive URL parameters from VF page. Details in getting URL parameter in Lightning Application is below,
2) Wrap VF page in lightning component - See examples in developers blog
Refer this thread  in the stackexchange : http://salesforce.stackexchange.com/questions/138208/navigate-to-lightning-component-from-visualforce-in-salesforce1 


There isn't any documented way of doing that, but I was able to do so using a hack.

The Salesforce Lightning URL is something like "/one/one.app#_______" . The blank contains some encoded value in the URL. The encoded value is nothing but the details of the Component/Page in Base64 encoded form.

Use the below code in Javascript in Visualforce to navigate to Lightning Components-
var compDefinition = { 
    "componentDef" : "c:NewContact", 
    "attributes" :{ 
          "recordTypeId" : "012xxxxxxxxxxxx",
          "testAttribute" : "attribute value"
// Base64 encode the compDefinition JS object
var encodedCompDef = btoa(JSON.stringify(compDefinition));
window.parent.location = "/one/one.app#"+encodedCompDef;