Courseiva
User Interface →easyMultiple Choice

SF-PD2 User Interface Practice Question

A developer needs a Lightning Web Component to navigate the user to a specific Account record's detail page when a button is clicked. Which approach is correct?

⚠ Common exam trap

The trap here is looking for a declarative navigation base component, when navigation in LWC is actually performed through the NavigationMixin JavaScript mixin.

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

✓

Import NavigationMixin from lightning/navigation, extend the component class with it, and call this[NavigationMixin.Navigate] with a standard__recordPage page reference.

Client-side navigation in a Lightning Web Component is handled by the NavigationMixin from lightning/navigation. Extending the component class with the mixin and calling the Navigate method with a standard__recordPage page reference moves the user to the Account record page without a full reload. Manually setting the browser location, inventing a navigation base component, or fetching a URL from Apex all bypass the supported API and degrade the user experience.

Answer analysis

Option-by-option breakdown

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

  • ✓

    Import NavigationMixin from lightning/navigation, extend the component class with it, and call this[NavigationMixin.Navigate] with a standard__recordPage page reference.

    Why this is correct

    NavigationMixin from lightning/navigation provides client-side navigation in LWC. Extending the class with it and calling this[NavigationMixin.Navigate] with a page reference of type standard__recordPage and the record's Id navigates to the record detail page without a full page reload. This is the documented, supported pattern for this exact requirement.

  • ✗

    Use window.location.href to set the browser URL to the record's Id appended to the Salesforce instance domain.

    Why it's wrong here

    Assigning window.location.href forces a full page reload, discarding the Lightning Experience app context and any unsaved state. Hardcoding the instance domain also breaks in communities, mobile, and different orgs. NavigationMixin is the supported client-side navigation API, so manually manipulating the browser location is discouraged and produces a poor, brittle user experience.

  • ✗

    Call an Apex method annotated with @AuraEnabled that returns the record's URL and assign it to an anchor's href attribute.

    Why it's wrong here

    A server round trip to fetch a URL is unnecessary when NavigationMixin resolves the page reference entirely on the client. The returned URL would still need to be navigated to, and using a plain anchor could cause a full reload or lose app context. This adds latency and complexity while not using the platform's client-side navigation API, so it is not the correct approach.

  • ✗

    Import the lightning:navigation base component, place it in the template, and set its recordId attribute to the Account Id.

    Why it's wrong here

    There is no lightning:navigation base component that navigates by a recordId attribute. Navigation in LWC is performed through the NavigationMixin JavaScript mixin, not by declaring a base component in markup. This option invents a component and attribute that do not exist, so it would fail at compile or render time and cannot perform the required navigation.

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.