Courseiva
User Interface →easyMultiple Choice

SF-PD2 User Interface Practice Question

A developer is building a Lightning Web Component that includes a button. When the button is clicked, the component must navigate the user to a specific Account record page in Lightning Experience. Which approach should the developer use?

⚠ Common exam trap

The trap here is using a full page reload via window.location or an anchor tag instead of the client-side NavigationMixin, which preserves the Lightning Experience context.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Use the NavigationMixin from lightning/navigation and call this[NavigationMixin.Navigate] with a standard__recordPage page reference.

NavigationMixin provides a navigate method that accepts a page reference object. For a record page, the page reference type is standard__recordPage with the recordId and actionName attributes. This performs client-side navigation within Lightning Experience, preserving the app context and working in the mobile app. It is the documented, supported pattern for navigating from an LWC.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Use the lightning-formatted-url component with the record ID and target set to _self.

    Why it's wrong here

    lightning-formatted-url renders a hyperlink but does not perform programmatic navigation on a button click. It also requires a static URL pattern and does not integrate with the Lightning Experience router. Using it inside a button's click handler would not navigate the user to the record page in the intended way.

  • ✗

    Set window.location.href to the record's URL constructed from the Salesforce instance domain.

    Why it's wrong here

    Assigning window.location.href triggers a full page reload and bypasses the Lightning Experience client-side router. Hardcoding or constructing the instance domain is fragile and breaks in different orgs or when the domain changes. This approach also does not leverage the supported navigation service, so it may fail in the Salesforce mobile app and other containers.

  • ✗

    Call the Apex method that returns the record URL and then assign it to a property bound to an anchor tag.

    Why it's wrong here

    Fetching a URL from Apex and binding it to an anchor still results in a full page load and does not use the navigation service. It also adds unnecessary server round-trips and does not handle navigation in the Salesforce mobile app. The supported client-side navigation approach is NavigationMixin, not a server-supplied URL.

  • ✓

    Use the NavigationMixin from lightning/navigation and call this[NavigationMixin.Navigate] with a standard__recordPage page reference.

    Why this is correct

    NavigationMixin adds a navigate method to the component. Passing a page reference with type standard__recordPage and the recordId attribute directs the user to the record's page in Lightning Experience. This is the supported way to perform client-side navigation from an LWC without a full page reload, and it works across Lightning Experience and the Salesforce mobile app.

About these practice questions

This SF-PD2 question is part of Courseiva's 226-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Salesforce exam blueprint

This SF-PD2 practice question is part of Courseiva's free Salesforce certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SF-PD2 exam.