lightning-navigation-dead-link-handling
Use when an LWC navigates via NavigationMixin to records or pages that may no longer exist, lack the user's access, or be permanently moved. Triggers: 'lightning navigation 404', 'navigate to deleted record', 'NavigationMixin error toast', 'graceful fallback when target page missing', 'permission denied on navigation'. NOT for general routing within an SPA or for Experience Cloud public-facing routing.
Best use case
lightning-navigation-dead-link-handling is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Use when an LWC navigates via NavigationMixin to records or pages that may no longer exist, lack the user's access, or be permanently moved. Triggers: 'lightning navigation 404', 'navigate to deleted record', 'NavigationMixin error toast', 'graceful fallback when target page missing', 'permission denied on navigation'. NOT for general routing within an SPA or for Experience Cloud public-facing routing.
Teams using lightning-navigation-dead-link-handling should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/lightning-navigation-dead-link-handling/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How lightning-navigation-dead-link-handling Compares
| Feature / Agent | lightning-navigation-dead-link-handling | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Use when an LWC navigates via NavigationMixin to records or pages that may no longer exist, lack the user's access, or be permanently moved. Triggers: 'lightning navigation 404', 'navigate to deleted record', 'NavigationMixin error toast', 'graceful fallback when target page missing', 'permission denied on navigation'. NOT for general routing within an SPA or for Experience Cloud public-facing routing.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Lightning Navigation Dead-Link Handling
Activate when an LWC's `NavigationMixin.Navigate` may target a record or page the user can't reach — deleted records, sharing-restricted records, retired Lightning pages, or component-named targets that have been removed. The skill produces a pre-navigation guard, a graceful failure path, and a user message that doesn't leave them on a blank screen.
---
## Before Starting
Gather this context before working on anything in this domain:
- The navigation target type: `recordPage`, `comm__namedPage`, `standard__webPage`, etc. Each fails in distinct ways.
- The user's expected access path. A reportable record may have been shared at one point and lost access later; a deep link from an email sent yesterday may target a record deleted today.
- The downstream UX expectation. Some teams want a toast + stay-in-place; others want a redirect to a "default" page; service console teams sometimes want to open a different subtab as fallback.
---
## Core Concepts
### Failure modes
| Failure | Surfaces as | Detection |
|---|---|---|
| Record deleted | Lightning shows "Insufficient privileges" or generic error | Pre-navigation `getRecord` returns error with `INVALID_ID` |
| User lacks access | "Insufficient privileges" toast | Pre-check via UI API; or wire `getRecord` and inspect error |
| Lightning page retired/unpublished | Blank tab, no toast | `getNavigationItems` doesn't return target — must validate before navigating |
| Component target removed | Console error in dev tools, blank surface | Caught only at the destination's `connectedCallback` |
| External URL 404 | Browser tab shows external 404 | Cannot detect from LWC; can only set `window.open` and let browser handle |
### NavigationMixin contract
`NavigationMixin.Navigate(pageReference, replace)` returns a promise that **resolves** as soon as Lightning *initiates* the navigation, not when the target finishes loading. The promise does not reject for inaccessible records — Lightning navigates, then the destination throws inside its own component lifecycle. That means catching errors with `.catch()` on the Navigate call alone is insufficient.
### Pre-navigation validation
The reliable pattern is to validate the target *before* calling Navigate. For records, use `getRecord` from `lightning/uiRecordApi` to confirm existence + access. For named pages, query `getNavigationItems` to confirm publish status. For external URLs, accept that detection isn't possible from the LWC and surface a "this may take you outside Salesforce" warning.
---
## Common Patterns
### Pattern: pre-flight `getRecord` check
**When to use:** Navigating to a record passed in via custom button, deep link, or stale tab.
**How it works:** Call `getRecord({ recordId, fields: ['Id'] })` first. If the wire returns an error, show a friendly message and don't navigate. If success, call `NavigationMixin.Navigate`.
**Why not the alternative:** Calling Navigate on a deleted record drops the user into an opaque error page with no way back to context.
### Pattern: navigation-items existence check
**When to use:** Navigating to a `comm__namedPage` or a navigation menu item that may have been retired.
**How it works:** Wire `getNavigationItems` (or call it imperatively) at component connect time. Cache the available targets. Validate the requested target against the cache before each Navigate. If absent, show a "this destination is no longer available" message and (optionally) navigate to a default page.
### Pattern: console-aware fallback
**When to use:** In Service Console, the user clicked a link that should open a subtab; the target record is gone.
**How it works:** Use `lightning/platformWorkspaceApi` to detect console context. On dead link, instead of opening a broken subtab, open a "lookup the right record" search subtab keyed by the original record name (if known) so the user has a recovery path.
---
## Decision Guidance
| Target type | Recommended pre-check | Failure UX |
|---|---|---|
| Record (recordPage) | `getRecord` wire | Toast + stay in place; offer search-by-name |
| Standard named page | None (always available) | n/a |
| `comm__namedPage` (Experience Cloud) | `getNavigationItems` | Toast + redirect to community home |
| `standard__webPage` (external) | None possible | Open in new tab + warning |
| Component-named (`standard__component`) | `getNavigationItems` doesn't cover; document expected components in source | Stay in place |
---
## Recommended Workflow
1. Identify the navigation target type and the most likely failure mode for the calling context (deep link from email, in-app button, console subtab, etc.).
2. Add a pre-navigation check appropriate to the target type. For records, wire `getRecord` and only enable the navigate trigger when the wire returns success.
3. Wrap the actual `NavigationMixin.Navigate` call in a try/catch with an error path, even though most failures don't surface there — defense in depth.
4. Define the fallback UX. A toast is always table-stakes; for high-value journeys, define a recovery route (alternative page, search-by-name, contact-admin link).
5. Log the failure (custom event to a parent logger, or a Lightning Platform Event publish for analytics) so the team learns where dead links cluster.
6. Test by manually deleting a record between page-load and click, confirming the user lands on the fallback rather than the broken page.
---
## Review Checklist
- [ ] Pre-navigation existence/access check appropriate to the target type
- [ ] `Navigate` call wrapped in try/catch with explicit failure path
- [ ] Fallback UX defined (toast, redirect, in-place message) — not silent
- [ ] Failure logged or eventized so dead-link patterns are observable
- [ ] Console-context detection if relevant
- [ ] Tests cover both success and failure paths
---
## Salesforce-Specific Gotchas
1. **`Navigate` resolves before the destination loads** — A `.then()` on Navigate runs before the destination decides it can't render. Don't put success logic in the `.then()` of Navigate.
2. **`getRecord` error semantics differ for deleted vs. no-access** — Deleted gives `INVALID_ID`; no-access gives `INSUFFICIENT_ACCESS_OR_READONLY`. Distinguish in your error UX.
3. **Experience Cloud guest user navigation may silently no-op** — Guest users without access to a target get no toast at all. Always pre-check.
4. **`NavigationMixin` is not available in headless Aura sites** — Confirm host context; fall back to `window.location.assign` only when truly necessary and origin-checked.
5. **Console workspace navigation is not the same as page navigation** — Use the workspace API for subtab actions; mixing the two leads to subtabs opening as new tabs instead.
---
## Output Artifacts
| Artifact | Description |
|---|---|
| Navigation handler module | Pre-check + Navigate + fallback flow as a reusable LWC module |
| Failure UX components | Toast, "page no longer available" placeholder, contact-admin link |
| Telemetry event | Custom event or Platform Event documenting dead-link occurrence for observability |
---
## Related Skills
- lwc/lwc-imperative-apex — for cases where the pre-check needs an Apex SOQL rather than `getRecord`
- lwc/common-lwc-runtime-errors — for the broader catalog of runtime failures including those that surface after navigation
- lwc/headless-experience-cloud — for navigation in headless contexts where `NavigationMixin` is partially unavailableRelated Skills
omnistudio-error-handling-patterns
Use when designing fault behavior across Integration Procedures, DataRaptors, OmniScripts, and FlexCards — error routing, user-facing messaging, retry semantics, and idempotency. Triggers: 'omnistudio error', 'integration procedure fault', 'dataraptor error handling', 'omniscript retry', 'flexcard action failure'. NOT for general Apex exception design or Flow fault paths.
tableau-embedding-in-lightning
Embedding Tableau dashboards (and Tableau Pulse insights) inside Lightning App / Record / Home pages — Tableau Embedding API v3 in an LWC, the connected-app + JWT trust pattern for SSO from Salesforce to Tableau, row-level security so a Salesforce user only sees their data in Tableau, CSP / Trusted Sites configuration for the Tableau host, and the Tableau Viz Lightning Web Component (drag-and-drop alternative to a custom LWC). NOT for building Tableau dashboards / data sources (that's Tableau-side work), NOT for CRM Analytics (Tableau is the separate product; see data/crm-analytics-patterns).
navigation-and-routing
Use when implementing or reviewing Lightning Web Component navigation with `NavigationMixin`, PageReference objects, URL state, and `CurrentPageReference` across Lightning Experience, mobile, and Experience Cloud. Triggers: 'navigate to record page from LWC', 'PageReference state not working', 'should I use window.location', 'Experience Cloud navigation issue'. NOT for component-to-component messaging or data-loading strategy when navigation is only a side effect.
lwc-navigation-mixin
NavigationMixin for LWC: PageReference types (recordPage, recordRelationship, namedPage, webPage, comm__namedPage), navigate vs generateUrl, state params, Experience Cloud variants. NOT for routing inside custom SPA (use lwc-state-management). NOT for cross-app deep-linking (use deep-linking-patterns).
lwc-lightning-record-forms
Lightning Data Service form components for LWC — when to use lightning-record-form vs lightning-record-edit-form vs lightning-record-view-form, output-field vs input-field, density modes, layout types (Compact/Full), and the platform-managed validation/save/error UI. NOT for fully custom form layouts (use lwc/lwc-custom-form-with-uiRecordApi) or aura:recordEditForm (Aura is deprecated for new work).
lwc-lightning-modal
LightningModal base class (Winter '23+): extending LightningModal, open() static method, modal headers/bodies/footers, close() with result, size variants, accessibility. NOT for lightning-dialog legacy patterns (deprecated). NOT for in-page overlays (use SLDS popover).
error-handling-in-integrations
Use this skill to design orchestration-layer error handling for Salesforce integrations — covering Platform Event replay recovery, dead-letter queue routing, cross-channel error notification patterns, circuit breaker design, and trigger suspension recovery. Trigger keywords: integration error handling, Platform Event retry, integration dead letter queue, EventBus RetryableException, integration circuit breaker, event bus trigger suspended. NOT for Apex exception handling (use apex-exception-handling skill), HTTP error response contracts (use api-error-handling-design), or retry backoff patterns (use retry-and-backoff-patterns).
api-error-handling-design
Designing HTTP error classification, RFC 7807-style error payload structure, and client-side error parsing for Salesforce REST/SOAP integrations and custom Apex REST endpoints. Use when deciding which HTTP status codes to return from custom Apex REST services, how to structure error response bodies, how to classify inbound API errors as retry-safe vs non-retry-safe, or how to parse Salesforce error responses on the consumer side. NOT for retry execution mechanics or circuit breaker implementation (use retry-and-backoff-patterns). NOT for Apex exception class design (use apex-error-handling-framework). NOT for OAuth error flows (use oauth-flows-and-connected-apps).
fault-handling
Use when designing, reviewing, or troubleshooting Salesforce Flow fault handling, error logging, and bulk-safe automation paths. Triggers: 'fault connector', '$Flow.FaultMessage', 'flow failed', 'record-triggered flow rollback', 'screen flow error'. NOT for generic Flow type selection unless the main risk is failure handling; NOT for Apex exception handling (see apex/exception-handling-patterns).
exception-handling
Use when writing, reviewing, or debugging Apex exception handling, DmlException behavior, custom exception hierarchies, or user-safe error messages. Triggers: 'DmlException', 'swallowed exception', 'AuraHandledException', 'trigger rollback', 'try catch'. NOT for choosing async execution models or general governor-limit tuning.
error-handling-framework
Use when designing or implementing a cross-cutting Apex error handling framework: custom exception hierarchies, rollback-safe logging via Platform Events, BatchApexErrorEvent processing, correlation ID threading, or a unified catch/log/rethrow utility class. Trigger keywords: 'error framework', 'centralized logging', 'rollback-safe log', 'BatchApexErrorEvent', 'correlation ID async', 'AuraHandledException boundary', 'Error_Log__c design'. NOT for individual try/catch block syntax help, basic DmlException handling, or choosing between synchronous and asynchronous execution models.
lightning-page-performance-tuning
Use when a Lightning record page, home page, or app page is slow to load or render — covers Experienced Page Time (EPT) analysis, component count reduction, progressive disclosure via tabs and conditional rendering, Lightning Experience Insights diagnostics, and DOM/XHR minimization strategies. Triggers: 'Lightning page is slow', 'EPT is high', 'record page takes too long to load', 'too many components on page', 'Lightning Experience Insights shows slow page', 'how to optimize Lightning page performance'. NOT for Visualforce page performance (separate concern). NOT for Apex or SOQL query optimization (use apex/apex-cpu-and-heap-optimization or data/soql-query-optimization). NOT for report or dashboard performance (use admin/report-performance-tuning).