In this paper, we study cluster sets and essential cluster sets for Sobolev functions and quasiharmonic functions (i.e., continuous quasiminimizers). We develop their basic theory with a particular emphasis on when they coincide and when they are connected. As a main result, we obtain that if a Sobolev function u on an open set has boundary values f in Sobolev sense and f | ∂ is continuous at x 0 ∈ ∂ , then the essential cluster set C(u, x 0 , ) is connected. We characterize precisely in which metric spaces this result holds. Further, we provide some new boundary regularity results for quasiharmonic functions. Most of the results are new also in the Euclidean case.