Optogenetics offers unique, temporally precise control of neural activity in genetically targeted specific neurons that express light-sensitive opsin molecules. Three-dimensional (3D) delivery of optogenetics can be realized by co-injection of bacteriorhodopsin (HEBR) plasmid with a chitosan-based self-healing hydrogel with strong shear-thinning properties. The HEBR protein shows photoelectrical properties and can be used as an optical switch for cell activation. We optimize the shear force generated during the process of injection ( approximately 100Pa), which is transient because of the self-healing nature of the hydrogel. This transient force exerted by the self-healing hydrogel may allow the cytosolic delivery of HEBR plasmid with excellent cell viability and a high efficiency approaching 80%. When excited with green light, HEBR-delivered neural stem cells (NSCs) can proliferate and specifically differentiate into neurons in vitro and rescue the function of nerve impaired zebrafish in vivo. This novel optogenetic method combining 3D injectable self-healing hydrogel offers potential temporal-spatial approaches to treat neurodegenerative diseases in the future.