The answer to 'how to replace recessed lighting' is to first turn off power to the circuit at the circuit breaker. Then, use a screwdriver to remove the trim ring or bezel around the recessed light. Next, disconnect the electrical wiring from the light fixture, being careful not to damage the wires. Remove the old fixture and install the new one, making sure to securely connect the wires. Finally, replace the trim ring and turn the power back on to test the new light.
Replacing recessed lights is a relatively simple DIY project, but it's important to take safety precautions and turn off power before working on any electrical components. If you're not comfortable working with electrical wiring, it's best to hire a licensed electrician to handle the job.