Do we have alternative of force:hasRecordId for LWC

In looking at this page of the LWC developer guide, I have not found any details around this.

Clearly to get an LWC working for a record page you can use target for RecordPage as below, making this component available to Account Page. But I need the recordId as well


What is required in order to make the record ID available to my component?


You can get the recordId by creating a property with @api recordId;.


// testClass.js
import { LightningElement, api } from 'lwc';
export default class TestClass extends LightningElement {
    @api recordId;

Source : Link , Question Author : Mekyush Jariwala , Answer Author : John Towers

Leave a Comment