Britney Spears can have sleepovers with her two boys — if she has regular drug and alcohol tests, childproofs her home and buckles the kids in car seats, a court commissioner ruled Tuesday.

The pop star, who is seeking to regain the shared custody she lost earlier this month, also must continue meeting with a court-appointed parenting coach, Superior Court Commissioner Scott Gordon ruled.

Calls to lawyers representing Spears, 25, and her ex-husband Kevin Federline, 29, were not immediately returned.

The nine-page ruling said Spears could have overnight visits with her kids — something she had been seeking. She will get two visits a week from noon to 7 p.m. and one from noon to 10 a.m. the next morning. All the visits will be monitored.

The order also cited some details of an Oct. 19 report submitted by parenting coach Lisa Hacker about her observations of Spears with Sean Preston, 2, and Jayden James, 1.

The report makes it clear that Hacker feels Spears "loves her children and the children are bonded" to her, the ruling states.

However, Hacker was concerned that Spears didn't seem to have "child-centered" interactions, according to the ruling.

The "environment at the house ranged from chaotic to almost somber with little communication at all," Hacker reported, according to the ruling.

During all three of her visits, Spears "rarely engaged with the children in either conversation or play," Hacker said in her report.

Hacker also reported that Spears seemed to have a "lack of general attention at times" but added there was nothing she "would characterize as abusive in a traditional sense."

Hacker added that during an additional visit Oct. 23, Spears seemed "much more engaged with (Hacker) and the children," the ruling stated.

Last year, authorities went to Spears' home to investigate after she was photographed driving with Sean on her lap. Gordon addressed the issue in his ruling.

"The minor children are not to be transported in a motor vehicle by any party unless the children are properly secured in a properly installed child safety seat," the ruling said.

The ruling came after a three-hour hearing last Friday attended by both Spears and Federline. Extensive testimony was presented on a number of issues.

Gordon previously said there was evidence that Spears is a "habitual, frequent and continuous" user of drugs and alcohol.

He had withdrawn approval for her to even visit the children after finding she had failed to comply with some conditions for shared custody.

He later withdrew the ban and allowed her to visit Sean and Jayden — but only in the presence of a court-approved monitor.

Spears had filed a request Friday to "terminate or modify" the order, according to court records. Additional details about the request weren't disclosed.