Access to the electron spin is at the heart of many protocols for integrated
and distributed quantum-information processing [1-4]. For instance, interfacing
the spin-state of an electron and a photon can be utilized to perform quantum
gates between photons [2,5] or to entangle remote spin states [6-9].
Ultimately, a quantum network of entangled spins constitutes a new paradigm in
quantum optics [1]. Towards this goal, an integrated spin-photon interface
would be a major leap forward. Here we demonstrate an efficient and optically
programmable interface between the spin of an electron in a quantum dot and
photons in a nanophotonic waveguide. The spin can be deterministically prepared
with a fidelity of 96\%. Subsequently the system is used to implement a
"single-spin photonic switch", where the spin state of the electron directs the
flow of photons through the waveguide. The spin-photon interface may enable
on-chip photon-photon gates [2], single-photon transistors [10], and efficient
photonic cluster state generation [11]