Both for humanitarian and political reasons, the Biden administration needs to get ahead of the developing situation at the southern border. The surge of would-be migrants is predictable, and the solution is clear: Just do the right things, and get children out of detention as soon as possible. And do it right now.

It should surprise no one that asylum seekers and others clamoring for entry into the United States would think they have a better chance of success now that racism, xenophobia and deliberate cruelty are no longer official U.S. policy. It is only logical that increased numbers would present themselves at the border or try to make their way into the country without permission.

It also should surprise no one that Republicans would react not with understanding but with political calculation. They know that immigration is an issue that riles up the GOP base and that also gets the attention of many independents — it was, after all, the most consistent theme of former president Donald Trump’s winning 2016 campaign. Republicans have already begun trying to paint the significant but hardly overwhelming border surge as a full-blown “crisis” that they hope will help them win House and Senate seats in 2022.

President Biden and his team need to neutralize this political ploy before it gains traction. That means the administration must act swiftly and decisively to get these children to people who love them — while remaining true to its stated values of compassion and respect for all who seek to come to the United States in search of safety and opportunity.

The most urgent plight is that of the nearly 3,500 minors who entered the country without their parents and are being held at Border Patrol stations in cells designed for adults. According to The Post, they are being housed in such grim conditions, on average, for 107 hours — much longer than the 72-hour legal limit.

Despite what some Republicans may claim, children are not being held in cages like they were during the Trump administration. Most importantly, they are not being forcibly separated from their parents as a way of deterring would-be migrants from legally seeking asylum — the outrageous Trump-era policy of state-sponsored kidnapping that I have long believed should be the subject of criminal investigation.

Nonetheless, it is unacceptable for the Biden administration to violate the 72-hour rule. Border Patrol detention of minors must be brought into compliance now.

The children should be quickly moved to shelters where full medical, psychological, educational, recreational and legal services are provided — but only temporarily, until they can be placed in the homes of family members or sponsors. The problem is that capacity in the shelters — presently housing about 8,500 additional children, according to The Post — is being severely constrained by the covid-19 pandemic. The shortage of shelter beds means delays in getting kids out of those Border Patrol cells.

So the Biden administration needs to do two things. First, it needs to create more shelter space, at least in the short term. Reopening a mothballed, 700-bed Trump-era shelter for migrant teens in Carrizo Springs, Tex. — a step the Department of Health and Human Services took last month — was probably necessary, but it’s not a good look for an administration trying to turn the page. New shelters are needed, and they must be put into service with the same urgency the administration summons for coronavirus vaccination centers.

The other thing the administration must do is move children out of the shelters into family or sponsor custody faster. This is mostly a matter of bureaucratic efficiency. Many of these “unaccompanied” minors actually were accompanied when they crossed the border, but by their grandparents, aunts, uncles or older siblings — not their parents. Biden needs to flood the zone with enough investigators, lawyers and other personnel to speedily determine that these relatives are in fact relatives, not traffickers, so these families can be promptly reunited.

Just as Biden and his aides decided to err on the side of doing too much rather than too little on covid-19 relief, they should go big on the border. When the pandemic does end, existing shelter space should be enough to handle the kind of surge we’re seeing now — but that day could be many months away. The system is overloaded this minute.

As a matter of politics, it is unwise for Biden to give Republicans fodder for demagoguery about a supposed border “crisis.” It is equally unwise to give progressive Democrats any reason to complain that his border policy is less than a complete departure from Trump’s.

And as a matter of policy, Biden must keep his eye on one guiding star: We are talking about the lives and well-being of children. It is nothing less than our duty to love and care for them as if they were our own.