R4 was an astromech droid who served the Resistance's Black Squadron during the early stages of the Cold War. In 34 ABY, he accompanied BB-8, O-R10N, and R2-HA on a mission to the planet Megalox Beta. While Poe Dameron and the other Black Squadron pilots traveled down to the prison Megalox to negotiate with Grakkus about the whereabouts of the explorer Lor San Tekka, R4 and his fellow droids remained aboard the space station that projected a gravity field protecting the prison from Megalox Beta's high gravity.
When the First Order Agent Terex complicated the mission, Poe got BB-8 to lead the other astromech droids on a mission to disable Megalox's gravity shield generator. R4 and the droids disembarked from their T-70 X-wing starfighters and headed towards the generator. On the way, R4 and R2-HA tried to access a network terminal. When three prison guards arrived, the droids donned their rocket boosters to stay hidden. However, R4's rocket boosters malfunctioned and he crashed on top of a guard, knocking him out. O-R10N knocked out the other guards and then helped R4 up.
The four droids soon made their way to the primary security field generator on Deck Twelve and began their work. However, they were discovered by a security droid, which fought O-R10N and BB-8. The droid hurled O-R10N down a bridge but BB-8 managed to disable the droid by electrocuting it. This enabled R4 and R2-HA to disable the gravity field on Megalox prison. After Poe and Black Squadron returned with Grakkus, the droids reunited with their pilots at the space station.
They then departed into space with Grakkus. When Agent Terex attacked the space station, Black Squadron launched an attack on his ship Carrion Spike, forcing the First Order agent to retreat. After securing information about Lor San Tekka from Grakkus, R4 presumably accompanied the other droids and Black Squadron back to the Resistance base on D'Qar.
R4 was an R4 astromech droid who was a member of the Resistance. He was equipped with a rocket booster. R4 was able to operate machinery such as network terminals and gravity shield generators.