Want to keep your old iPhone's battery in top condition? Follow Apple's tips! Turn on Optimized Battery Charging, which learns from your daily routine and waits to finish charging past 80% until you need it. Avoid extreme temperatures (above 95°F/35°C) by keeping your phone out of direct sunlight and not leaving it in the car for extended periods. Remove bulky cases that can trap heat while charging, and avoid processor-intensive apps when your phone is charging.
Source: https://www.cnet.com/tech/mobile/how-to-keep-your-old-iphones-battery-in-top-condition/#ftag=CAD590a51e