Skip to main content
Dynamic interactions allow your Lightning Web Components to respond to user actions in real-time, fetch data on demand, and create rich, interactive experiences.

Imperative Apex Calls

While @wire is declarative and caches results, imperative Apex calls give you full control over when and how data is fetched.

Basic Imperative Call

Imperative with Parameters

Refreshing @wire Data

Combine @wire for initial load with imperative calls for refresh:

Dynamic Navigation

Use the Navigation Service to navigate to different pages programmatically.

Generate URL for Navigation

Dynamic Component Creation

Create components dynamically at runtime.

Template-based Dynamic Components

Real-Time Updates with Platform Events

Subscribe to platform events for real-time data updates.

Debouncing User Input

Prevent excessive API calls by debouncing user input.

Polling for Updates

Periodically check for data updates.

Progress Indicators

Show progress for long-running operations.

Best Practices

Use @wire for Initial Load, Imperative for Actions

Handle Errors Gracefully

Clean Up Resources