Get Record Id dynamically in LWC
In many scenarios we need to have current record id in the lightning web component. Id we want get current record id then we need to define "recordId" prublic property in corresponding lwc component JavaScript file and the lightning web component should be added into lightning record page.
How To Fetch Current Record Id In Lightning Web component Example
import { LightningElement, api } from 'lwc';
export default class LwcGetRecordId extends LightningElement {
@api recordId;
}
lwcGetRecordId.html
<template>
Current Record Id : {recordId}
</template>
Output: Add above ligtning web component to any of the record page(Ex: Account, contact, opportunity....)
No Comment to " How To Get Current Record Id In LWC (Lightning Web components) "