To obtain the protection you desire, develop a written formal contract for the development services that you and the freelancer sign; you as the buyer and the freelancer as the supplier.
The contract must specify that the product development services for your App, in addition to web functionality, are a deliverable item under the contract, subject to your approval as an acceptably functioning product before payment.
Product acceptance criteria should be contained in a specification attached to the contract. The specification should detail what and how the App is expected to perform. The contract should also specify that the deliverable item includes delivery to you of the code in digital format.
The contract should further state that the developer may not, without your permission, disclose to others, utilize or otherwise benefit from the deliverable and its code and that the developer is not permitted to copy the digital media he delivers to you for purposes of further use or sale to others.
https://www.smalltofeds.com/2013/06/practical-intellectual-property.html