Can we import Apex variables from LWC?

Is it possible to import Apex variables from Apex class into LWC? Let's check out.

By know you would have known that we can import Apex methods into LWC either using @wire operator or imperatively.

That gets us to the next question, can we import Apex variables from Apex classes into LWC (as shown below)?

@AuraEnabled
public String accountName;
import { LightningElement, wire } from "lwc";

import accountName from "@salesforce/apex/AccountController.accountName";

export default class VzWireApexController extends LightningElement {
  
}

Take a guess before I reveal the suspense!

Am still waiting for your answer :p

Okay let me tell you my version! No, we cannot import Apex variable from Apex class.

Subscribe to Salesforce Casts

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe