Starship personnel live in quarters on ship (also called cabins, staterooms). Depending on the facilities available, their rank, and their length of service, these may vary from a bunk in a shared cabin to a personal suite with bathroom, living area, office area, and food slots or replicators.
Earth Starfleet (22nd century)
NX class cabins were small and spartan because there was limited space for accommodation. Few cabins had windows. (ENT)
Starfleet (23rd century)
Early 23rd century Starfleet vessels have limited space, so junior officers and crewmen share quarters. On Shinjuku-class vessels these cabins have bunk beds, clothes storage, a desk, chair, and storage locker that doubles as a bench. There are no windows or food slots. Officers have cabins in the saucer section, crew in the engineering hull. The captain's quarters are aft of Deck B, with a living area with windows and a view of the warp engines. (TOSS)
In the late 23rd century, large starships (explorers like USS Enterprise give individual cabins to officers of rank lieutenant and above, and crew of rating petty officer and above. The captain's quarters include food slot, recycler, and office areas. Low-ranking crew still share cabins. Cabins do not have windows. (TOS; Star Trek VI: The Undiscovered Country)
Smaller warships have more spartan accommodation, with most officers sharing cabins. (TOS novel The Entropy Effect)
Starfleet (24th century)
In the late 23rd and 24th centuries, larger starships (such as Galaxy class and Intrepid class) give individual cabins to officers of rank lieutenant junior grade and above, and crew of rating petty officer and above. Cabins include food replicator, a small bathroom, and customizable furniture. Senior officers' cabins are along the saucer rim, with windows looking out onto space. Couples may choose to share a room. (TOS, TNG, VOY, Star Trek: The Cantabrian Expeditions; Star Trek: Hidden Frontier)
The decentralized layout of Borg cubes does not include crew quarters. Regeneration points were distributed throughout the work areas.
Brianna Reiss likened the officer cabins on Lyran Starfleet starships as being roughly equivalent to 23rd-century Federation Starfleet. This held true in both starships and starbases. As such, officers ranked lieutenant and above had access to individual cabins. (RIS Bouteina: "Broken Bread")
Mandy Guilmain commented that Stoneship-class starships were more comfortable than their predecessors; the captain's cabin was similar to Galaxy-class senior officer cabins, rather than junior officer cabins as was the case on older ships. (Star Trek: The Stoneship Files: "Chronicles of Taladu")
Norexan-class starships contained lavish officer cabins that included a replicator, an office space with a computer terminal, a sonic shower and a fully-detached bed, as well as customizable furniture. Such cabins were made available to erein and above. Senior officers had windows in their cabins while junior officers did not. Once again, couples had the choice of sharing a cabin, such as Pazzo and Zetra or Vaebn Mairex and Brianna Reiss (until the latter came back to Lyran Starfleet Intelligence) (RIS Bouteina various)