We propose a nanostructure switch based on nuclear magnetic resonance (NMR) which offers reliable quantum gate operation, an essential ingredient for building a quantum computer. The nuclear resonance is controlled by the magic number transitions of a few-electron quantum dot in an external magnetic field.