Quantum networks based on optically addressable spin qubits promise to enable secure communication, distributed quantum computing, and tests of fundamental physics. Scaling up quantum networks based on solid-state luminescent centers requires coherent spin and optical transitions coupled to photonic resonators. Here we investigate single $mathrm{{}^{171}Yb^{3+}}$ ions in yttrium orthovanadate coupled to a nanophotonic cavity. These ions possess optical and spin transitions that are first-order insensitive to magnetic field fluctuations, enabling optical linewidths less than 1 MHz and spin coherence times exceeding 30 ms for cavity-coupled ions. The cavity-enhanced optical emission rate facilitates efficient spin initialization and conditional single-shot readout with fidelity greater than 95%. These results showcase a solid-state platform based on single coherent rare-earth ions for the future quantum internet.