There are a couple options in terms of general types of technology.
One would be a Wi-Fi repeater, which would connect to relatively distant Wi-Fi networks and rebroadcast them inside the boat for your devices to use. Those are relatively inexpensive but you still need to be fairly close (within a few hundred yards) to a free publicly available Wi-Fi network.
Sounds like what you’re looking for is really a cellular hotspot that will provide Wi-Fi on the boat by bridging to a cellular network. Those can range from fairly inexpensive (~$50) to relatively complex, with varying capability to pick up weak cell signals. In any case they’d have a slot where you put a SIM card to connect to the cell network for whatever region your in. Pricing for those data plans will vary also.
At the top end would be Starlink, which would give you internet without needing to be in Wi-Fi or cellular range of shore. But that requires it’s own satellite antenna, Wi-Fi router on the boat, and data plan.