I would like to initiate OAuth web flow from a button on LWC in Lightning Experience, after redirect on VF page and from VF page back to the original Lightning Page from which the user started.

The problem is that Visualforce and Lightning use different structures for redirection. Visualforce use PageReference apex class while lightning use Navigation mixin.

I tried to redirect from one Visualforce page to another page where I put LWC in Lightning Out to call the redirection back to the original Lightning Page, but this doesn't work.

Listing of Visualforce Page to contain LWC to redirect back

    <c:LexOut component="c:red" dependencyApp="c:dep"/>

LexOut Visualforce Component for Lightning Out

<apex:component >
    <apex:attribute name="component" type="String" description="Component name" required="true"/>
    <apex:attribute name="dependencyApp" type="String" description="Dependency app name" required="true"/>

    <apex:includeLightning />
    <div id="host"/>
        var myUserContext = "{!$User.UITheme}";
        $Lightning.use("{!dependencyApp}", function() {
            { userContext: myUserContext },
            function(cmp) {

Aura Lightning Out Dependency App

<aura:application access="GLOBAL" extends="ltng:outApp">
    <aura:dependency resource="c:red"/>

LWC Red component

import { LightningElement } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
export default class Red extends NavigationMixin(LightningElement) {
    connectedCallback() {
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Account',
                actionName: 'home',

Apparently this doesn't work and I tried for now just hardcode the Navigation Mixin current page reference.

1 Answer 1


When you look at lightning-navigation, you'll see it's only supported in:

Lightning Experience, Lightning Communities, Salesforce Mobile App

Notably, it is not supported in Lightning Out. You'll need to come up with a different approach.

You must log in to answer this question.

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