Size-selective pores in the shells of hollow polymer nanocapsules enable combined assembly and entrapment of molecules. Small building blocks enter the capsule through the pores. The assembled molecules, which are larger than the pores, remain entrapped in the nanocapsules. Porous nanometre-thin walls permit unhindered functionalization of entrapped molecules.