WASHINGTON — Friends and family will be able to take the first step to save a loved one from an overdose of heroin or powerful painkillers called opioids.

The Food and Drug Administration on Thursday approved an easy-to-use device that automatically injects the right dose of an overdose antidote named naloxone before an ambulance arrives. Doctors could prescribe it for family members or caregivers to keep on hand, in a pocket or a medicine cabinet.

Opioids include legal prescription painkillers, such as OxyContin and Vicodin, as well as illegal street drugs like heroin.