Yes, online poker is legal in the United States, albeit only in certain states. As of early 2024, only six states have legalized online poker  Nevada, Delaware, New Jersey, Pennsylvania, West Virginia, and Michigan.
Basically, not all states allow online poker to be played within their borders. However, due to US federal law (The Wire Act) that prohibits moving funds for gambling of any type over state lines, all the players in a poker game must be within the state.