By the time April was winding down, RJ Allen had not played a professional soccer match in nearly two years. So he became a coach.

Allen got a gig coaching youth soccer for Staten Island United’s U-10 boys’ team, training kids and keeping himself in shape in case the call came for him to return to the pro ranks for the first time since he left Skive, a second-tier club in Denmark, in 2013.

“I’ve coached them on and off for a couple of years,” Allen said.

The coaching is “off” now. Allen is a starting wingback for New York City FC.

When injuries and inconsistent play struck NYCFC in its debut months, Allen received an invitation from head coach Jason Kreis to join the MLS expansion team for a training stint. After a few days, he was officially signed May 1.

He had trained with NYCFC last November and through the new year — one of several failed trial runs he’s had with MLS clubs — but the 25-year-old failed to make the squad after its combine in January.

“Honestly the first time he came to train with us, I thought he was very good,” NYCFC defender Chris Wingert said. “It’s hard to step in when you’re looking to impress.”

It didn’t take long for Allen to find the field after stepping in. On May 3, two days after being added to the roster, he appeared as a substitute in the 70th minute in a 3-1 loss to Seattle Sounders.

“Not that I was shocked, but I don’t think Jason brought me on to just to be a squad guy,” Allen said. “He wouldn’t have signed me if he didn’t believe in me, if he didn’t trust me on the field.”

A week later, Kreis’ trust grew further. Allen started and played the entire 90 minutes of the first Hudson River Derby against New York Red Bulls.

“It’s really impressive, and you like these stories in sports,” NYCFC defender Jeb Brovsky said. “He comes in and forces his way into the roster. He did very well doing that.”

Allen is a native of Old Bridge, NJ, who was named to the All-American second team in college at Monmouth. Starting his first MLS game in his home state, Allen made the most of the experience.

“The atmosphere in New Jersey was unbelievable,” Allen said. “Having over 1,500 fans travel across the Hudson and show their support was great. To get my first professional start in that environment was a great stepping stone for me.”

In a game full of misery for the visitors, Allen offered an element of creativity that NYCFC has desperately lacked, lacing a daring low cross inside the Red Bulls six-yard box where a streaking Patrick Mullins emphatically tapped in NYCFC’s lone goal in a 2-1 defeat.

But for Allen, the crowning moment was his parents getting to see him play in an MLS uniform.

“It’s the first time in a very long time that my parents got to see me play,” Allen said. “It’s always nice to be home, and it’s honestly a dream come true to play in New York, right in my hometown basically. I’m at a loss for words sometimes, but it’s a tremendous and crazy experience.”

Despite his emergence into NYCFC’s starting 11, Allen will miss Saturday night road test at Real Salt Lake after receiving a straight red card May 15 when he slide tackled Chicago Fire forward David Accam from behind inside the penalty box. The 10-man squad rallied for a 2-2 draw, their first point in four games.

“I’m just very blessed and happy to be here in New York,” he said. “It’s not always about how you’re acquired, but what you do when you’re acquired that makes you a good player or not.”

And what about his young pupils back on Staten Island?

“When I’m done playing, I’d love to get back,” Allen said. “For right now, playing is first and foremost what I want to do.”