The U.S. Supreme Court ruled unanimously on Monday that a North Carolina statute that prevents registered sex offenders from accessing social media sites where children are known to be online violates the First Amendment.

The case, Packingham v. North Carolina, concerned a registered sex offender who posted an exuberant message on his own Facebook profile in 2010 thanking God for the fact that a court had dismissed a traffic ticket: “Man God is Good! How about I got so much favor they dismissed the ticket before court even started? No fine, no court cost, no nothing spent. . . . . .Praise be to GOD, WOW! Thanks JESUS!” He was convicted and given a suspended sentence.

The defendant appealed his conviction and sentence, and the state appellate court agreed with him that the state law was unconstitutional. The North Carolina Supreme Court, however, disagreed and upheld the law as constitutional, on the argument that it served a legitimate state interest in protecting minors, and that there were alternative sites on which sex offenders could communicate without the risk that they might gather information about minor children.

The majority opinion, written by Justice Anthony Kennedy, held: “A fundamental principle of the First Amendment is that all persons have access to places where they can speak and listen, and then, after reflection, speak and listen once more.” Social media, Kennedy wrote, is one of those places:

On Facebook, for example, users can debate religion and politics with their friends and neighbors or share vacation photos. On LinkedIn, users can look for work, advertise for employees, or review tips on entrepreneurship. And on Twitter, users can petition their elected representatives and otherwise engage with them in a direct manner.

While the law is “content neutral,” and therefore only subject to the standard of “intermediate scrutiny,” Kennedy wrote, it is not “narrowly tailored to serve a significant governmental interest.” The law could theoretically bar access to newspaper websites as well, he added. The state could write a new law that was more specific in its application to the problem at hand, he suggested, such as prohibiting “contacting a minor or using a website to gather information about a minor.” But the current law was far too broad, he said, because it “bars access to what for many are the principal sources for knowing cur- rent events, checking ads for employment, speaking and listening in the modern public square, and otherwise exploring the vast realms of human thought and knowledge.”

The liberal justices — Elena Kagan, Sonia Sotomayor, Stephen Breyer, and Ruth Bader Ginsburg — all joined Kennedy’s opinion. The conservatives — minus Neil Grouch, who was appointed too late to participate — joined a concurring opinion, written by Justice Samuel Alito, which agreed with the majority that the North Carolina’s “extraordinary breadth” was a problem, but disagreed with what Alito called the majority’s “undisciplined” comments.

Specifically, Alito argued, the Court went too far in suggesting that social media were like other public forums, which could be construed as meaning “that the States are largely powerless to restrict even the most dangerous sexual predators from visiting any internet sites.” Alito wrote that the “fatal problem” for the law was that “its wide sweep precludes access to a large number of websites that are most unlikely to facilitate the commission of a sex crime against a child. A handful of examples illustrates this point.” And yet, he added:

But if the entirety of the internet or even just “social media” sites16 are the 21st century equivalent of public streets and parks, then States may have little ability to restrict the sites that may be visited by even the most dangerous sex offenders. May a State preclude an adult previously convicted of molesting children from visiting a dating site for teenagers? Or a site where minors communicate with each other about personal problems? The Court should be more attentive to the implications of its rhetoric for, contrary to the Court’s suggestion, there are important differences between cyberspace and the physical world.

In applying the First Amendment to the Internet, Alito concluded, “we should proceed circumspectly, taking one step at a time.”

Joel B. Pollak is Senior Editor-at-Large at Breitbart News. He was named one of the “most influential” people in news media in 2016. He is the co-author of How Trump Won: The Inside Story of a Revolution, is available from Regnery. Follow him on Twitter at @joelpollak.