[SalesForce] Getting Parameters in Lightning Web Components

This seems like a super simple question but I can't find the answer for the life of me. I have an app that is going to edit records in a new Lightning App Page with a Lightning Web Component in it.

When I go to this App Page, the Id is being passed as a URL parameter.

How do I get the value of a query string parameter in the js file of a Lightning Web Component?

Best Answer

You simply need to specify recordId as an @api member, and the framework will give you the ID automatically.

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

You should also be able to access window.location.search to identify parameters.