You can break hermit crabs into two basic kinds: marine crabs and land crabs. One group lives underwater, and the other spends the bulk of its time on land. Because of this, they have two different but related ways of getting oxygen.
Two Types of Hermit Crabs
For the sake of their care, hermit crabs can be divided into two groups. The first group is the marine hermit crabs. These crabs spend most of their life underwater and rarely leave for land. The second group, the land hermit crabs, spend most of their life on land but need access to both fresh- and saltwater to survive and breed.
Believe it or not, land hermit crabs have gills. They need high humidity to keep their gills damp. Most land hermit crabs keep some water in their shells to keep their gills damp. However, land hermit crabs require access to both freshwater and saltwater to keep their gills wet; otherwise the gills will dry out and the crab will suffocate.
Most hermit crabs are marine crabs. They rarely if ever leave the water. They are commonly kept in reef fish tanks. Many species exist, with differing compatibilities and temperaments. Like their land cousins, they breath through gills -- but they don't have to carry around their water to do so. Most can survive briefly out of water as long as their gills are damp. However, this ability is not as developed as it is in land hermit crabs.
With good care, both types of hermit crabs can survive for years. Many people treat land hermit crabs as "throwaway pets," not realizing that some species can live for more than 20 years. Proper care includes providing your hermit crabs with saltwater and freshwater, and giving them enough bedding to burrow into. Marine hermit crabs are easier; their gills require no special treatment by you to keep themselves alive.