The ability to manipulate single atoms has opened up the door to constructing interesting and useful quantum structures from the ground up. On the one hand, nanoscale arrangements of magnetic atoms are at the heart of future quantum computing and spintronic devices; on the other hand, they can be used as fundamental building blocks for the realization of textbook many-body quantum models, illustrating key concepts such as quantum phase transitions, topological order or frustration as a function of system size. Here, we use low-temperature scanning tunnelling microscopy to construct arrays of magnetic atoms on a surface, designed to behave like spin-1/2 XXZ Heisenberg chains in a transverse field, for which a quantum phase transition from an antiferromagnetic to a paramagnetic phase is predicted in the thermodynamic limit. Site-resolved measurements on these finite-size realizations reveal a number of sudden ground state changes when the field approaches the critical value, each corresponding to a new domain wall entering the chains. We observe that these state crossings become closer for longer chains, suggesting the onset of critical behaviour. Our results present opportunities for further studies on quantum behaviour of many-body systems, as a function of their size and structural complexity.