We determine the set of connected components of minuscule affine Deligne–Lusztig varieties for hyperspecial maximal compact subgroups of unramified connected reductive groups. Partial results are also obtained for non-minuscule closed affine Deligne–Lusztig varieties. We consider both the function field case and its analog in mixed characteristic. In particular, we determine the set of connected components of unramified Rapoport–Zink spaces.