I'm trying to override the new button on one of my objects with a lightning component. If this object is being created on an opportunity is there a way to get the id of that opportunity? If you override the new button with a visualforce page you can access the opportunity id in the url, so I'm just curious if theres a similar way to get the opp id with a lightning component.
I am assuming you are trying to create a new child record on an Opportunity, using the New button on related list.
Your lightning component must implement lightning:actionOverride and force:hasRecordId interface. You must also manually override the New button on the child object with the lightning component you created.
Doing so, Salesforce will automatically add a recordId attribute on your component, with the Opportunity record Id.
In your client side controller or helper, you can fetch the Opportunity record id using
Whenever a lightning component is embedded on the lightning record detail or page, lightning automatically adds the recordId in context, provided the hasRecordId interface has been implemented.
Salesforce document states that:
The recordId attribute is set only when you place or invoke the component in an explicit record context. For example, when you place the component directly on a record page layout, or invoke it as an object-specific action from a record page or object home.