We report on a new electrochemical cell setup, combined with a portable UHV chamber, for in situ x-ray diffraction using synchrotron radiation. In contrast to more traditional electrochemical sample preparation schemes, atomically clean and well-ordered surfaces are routinely prepared by UHV methods, even in the case of reactive elements or alloys. Samples can be transferred from larger UHV systems into the portable chamber without exposure to ambient air. They can then be studied successively in UHV, in controlled gas atmospheres, and in contact with electrolyte solutions under applied electrochemical potential. The electrochemical setup employs a droplet geometry, which guarantees good electrochemical conditions during in situ x-ray measurements combined with voltammetry. We present first experimental results of Cu deposition on GaAs(001) and on freshly produced nanometric Pd(001) islands on Cu(0.83)Pd(0.17)(001), respectively.