The getListUi wire adapter retrieves records and metadata for a Salesforce list view.
Import
import { getListUi } from 'lightning/uiListApi';
Parameters
The API name of the object for the list view.
The API name (developer name) of the list view.
Field to sort by. Can be a field reference from @salesforce/schema.
Number of records to retrieve per page. Default is 50, maximum is 2000.
Token for pagination to retrieve the next or previous page.
Basic Usage
import { LightningElement, wire } from 'lwc';
import { getListUi } from 'lightning/uiListApi';
import CONTACT_OBJECT from '@salesforce/schema/Contact';
import NAME_FIELD from '@salesforce/schema/Contact.Name';
export default class WireListView extends LightningElement {
@wire(getListUi, {
objectApiName: CONTACT_OBJECT,
listViewApiName: 'All_Recipes_Contacts',
sortBy: NAME_FIELD,
pageSize: 10
})
listView;
get contacts() {
return this.listView.data.records.records;
}
}
Using Schema References
Import object and field references for type safety:
import CONTACT_OBJECT from '@salesforce/schema/Contact';
import NAME_FIELD from '@salesforce/schema/Contact.Name';
@wire(getListUi, {
objectApiName: CONTACT_OBJECT,
listViewApiName: 'All_Recipes_Contacts',
sortBy: NAME_FIELD,
pageSize: 10
})
listView;
Response Data
The wire adapter returns:
{
records: {
records: [...], // Array of record data
count: 10,
currentPageToken: null,
currentPageUrl: '...',
nextPageToken: '...',
nextPageUrl: '...',
previousPageToken: null,
previousPageUrl: null
},
info: {
displayColumns: [...],
filterLogicString: null,
filteredByInfo: [...],
label: 'List View Label',
listReference: {...},
orderedByInfo: [...]
}
}
Accessing Records
get contacts() {
return this.listView.data?.records.records || [];
}
Use page tokens to navigate through results:
export default class PaginatedListView extends LightningElement {
pageToken = null;
@wire(getListUi, {
objectApiName: CONTACT_OBJECT,
listViewApiName: 'All_Recipes_Contacts',
pageSize: 10,
pageToken: '$pageToken'
})
listView;
handleNext() {
if (this.listView.data?.records.nextPageToken) {
this.pageToken = this.listView.data.records.nextPageToken;
}
}
handlePrevious() {
if (this.listView.data?.records.previousPageToken) {
this.pageToken = this.listView.data.records.previousPageToken;
}
}
}
Reactive Parameters
Make parameters reactive using the $ prefix:
export default class DynamicListView extends LightningElement {
listViewName = 'All_Recipes_Contacts';
@wire(getListUi, {
objectApiName: CONTACT_OBJECT,
listViewApiName: '$listViewName',
pageSize: 10
})
listView;
}
List View API Names
To find list view API names:
- Navigate to the list view in Salesforce
- Check the URL for the list view ID
- Use the developer name (API name) of the list view
Common list view API names:
AllAccounts
MyAccounts
RecentlyViewedAccounts
Source Examples
wireListView - Basic list view with sorting and page size