  One of the biggest challenges in experimental quantum information is to keep
the fragile superposition state of a qubit alive. Long lifetimes can be
achieved for material qubit carriers as memories, at least in principle, but
not for propagating photons that are rapidly lost by absorption, diffraction or
scattering. The loss problem can be mitigated with a nondestructive photonic
qubit detector that heralds the photon without destroying the encoded qubit.
Such detector is envisioned to facilitate protocols where distributed tasks
depend on the successful dissemination of photonic qubits, to improve
loss-sensitive qubit measurements, and to enable certain quantum key
distribution attacks. Here we demonstrate such a detector based on a single
atom in two crossed fibre-based optical resonators, one for qubit-insensitive
atom-photon coupling, the other for atomic-state detection. We achieve a
nondestructive detection efficiency upon qubit survival of $(79\pm3)\,\%$, a
photon survival probability of $(31\pm1)\,\%$, and preserve the qubit
information with a fidelity of $(96.2\pm0.3)\,\%$. To illustrate the potential
of our detector we show that it can provide, already with current parameters,
an advantage for long-distance entanglement and quantum-state distribution,
resource optimization via qubit amplification, and detection-loophole-free Bell
tests.
