function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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
Hi,
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,
http://salesforce.stackexchange.com/questions/106543/lightning-app-getting-url-parameter
2) Wrap VF page in lightning component - See examples in developers blog
https://developer.salesforce.com/blogs/developer-relations/2017/01/lightning-visualforce-communication.html
EldonEldon
Refer this thread  in the stackexchange : http://salesforce.stackexchange.com/questions/138208/navigate-to-lightning-component-from-visualforce-in-salesforce1 

https://developer.salesforce.com/forums/?id=906F0000000BFkXIAW

 
Yogesh.AroraYogesh.Arora
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-
 
<script>
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;
</script>