The short answer, perhaps surprisingly, is no. There are several
thousand different types, or species, of crabs, and the great
majority of them do indeed live in the sea. But there are also
hundreds of species - most in tropical countries - that live in
freshwater lakes and rivers, and some even on land. In fact we have
a type of freshwater crab in New Zealand: a small spider crab
(Amarinus lacustris) that grows to about 1 cm shell width and occurs
in some North Island lakes and rivers, though it prefers water that's
brackish (only slightly salty).

As you move from the open sea into a river mouth and up a river, then
the water gets less and less salty until it's completely fresh, with
no saltwater mixed with it. Many groups of animals that evolved in
the sea have species that have made this journey, moving from salt to
freshwater. This presents problems though, as the animal has to keep
a balance between the saltiness of its own body tissues and that of
the surrounding water.

Some crabs spend only part of their life in saltwater, like the
Chinese mitten crab (Eriocheir sinensis), so called because of its
furry front claws. In this species the young crabs live in
freshwater, but then migrate down to the sea to live as adults.
There is a real concern that this crab could be introduced into New
Zealand in ships' water ballast tanks, and that its burrows would
damage river banks.