The batteries in modern hybrids are designed to last for at least 100,000 miles. Some might even make it to 150,000 or more. If you're the original owner of a hybrid vehicle, chances are you won't ever have to replace the battery pack because it just wears out.
That said, hybrid batteries aren't immune to the laws of nature. Just like any other car part, they can unexpectedly fail. That's why automakers provide lengthy warranties. For example, Toyota offers a 100,000-mile battery warranty on the Prius here in California. The Hyundai Ioniq Hybrid benefits from a lifetime warranty.
If you're faced with replacing the battery on an out-of-warranty car, there's no need to panic. The cost of a new battery pack continues to decline and, last we checked, is at around $3,000, not bad when you consider how long they last. An approved used pack salvaged from a wrecked vehicle can set you back even less.
Battery replacement should be left to professionals. There are strict regulations for the handling and disposal of old batteries, which can leak hazardous materials. In fact, very few third-party mechanics are qualified to tackle the job. Almost all replacements are performed by dealers, who have the experience and know-how to do it the right way. New dealer-installed batteries come with full warranties, so you may be covered for the remainder of your ownership.
While there are many theories about how to make batteries last longer (coasting, slow takeoffs, etc.), they haven't been shown to actually extend battery life and are impractical anyway. Simply maintaining your vehicle as recommended is the best way to ensure your battery stays healthy for as long as possible.
When do you know it's time for a new battery? Your car will tell you. The gas engine will run almost constantly and your fuel economy will take a noticeable hit. While your car may run for some time on a bum battery, its performance and efficiency will steadily decline until it's replaced.