Mayor Bill de Blasio could be in trouble over a deal with developers to turn the Brooklyn Heights library into a luxury condo tower.

City and federal authorities are reportedly investigating whether developer Hudson Cos., whose president contributed to de Blasio’s campaign, was given favored status for the project.

In the past several months, several investigations linked to de Blasio have become public — including potential special treatment by the administration for donors from the real estate industry.

De Blasio, who has denied wrongdoing, should fight hard to rid his administration of conflicts of interest.

The investigations aside, the story of why the contract for the library project was awarded to Hudson, whose $52 million bid was less than a competitor’s, raises concerns over whether de Blasio is embedded with NYC real estate interests at the expense of the public interest.

The mid-century Brooklyn Heights library is stunning, historic and belongs to the public.

“Why should we be selling this beautiful, irreplaceable library at all?” Michael White of Citizens Defending Libraries, a group opposing the sale of the building, told the Brooklyn Eagle.

We shouldn’t. The public is losing a property and getting a smaller library in return. And if you believe the developers’ promises to give back to the community with affordable housing and millions of dollars for libraries elsewhere in Brooklyn, I’ve got a Barclays Center to sell you. I believe too many developers do not abide by so-called “community benefits” agreements. Those are usually made to appease resistant communities and are not always enforced.

A recent study by the Center for the Urban Future found that libraries were underfunded, with infrastructure crumbling, when the need for them is greater than ever. Even in this age of devices, library use in the city has been on the rise, along with our population.

The city should have kept the landmarked Brooklyn library building, and should fund the upkeep and repair of such venerable public assets.

Liza Featherstone lives and writes in Clinton Hill.