Residential smoke detectors / fire alarms in homes are usually designed to last about 10 years. You should replace your detectors within 10 years. This includes alarms connected to hardwired systems.
If you don’t know the age of an alarm, open the cover and look for an expiration or replacement date. If an alarm looks old and you can’t find a replacement date, replace the alarm anyway. They’re inexpensive and vitally important.

When replacing a hardwired alarm, you must match the alarm exactly. This requires identifying the type and model. Replacements are always available from the manufacturer. If your alarms are not hardwired, you can buy any type for replacement.
Modern smoke alarms are often combined with a carbon monoxide alarm. Often, these carbon monoxide alarms must be replaced every five years. Check the instructions on the alarm in your home.
Finally, remember to replace batteries in all alarms once a year. Use a heavy marker to write the replacement date on masking tape on the battery or, better yet, on the exterior of the alarm. You don’t want to miss the date for replacement.