Provided herein are in vivo gelling ophthalmic pre-formulations forming a biocompatible retinal patch comprising at least one nucleophilic compound or monomer unit, at least one electrophilic compound or monomer unit, and optionally a therapeutic agent and/or viscosity enhancer. In some embodiments, the retinal patch at least partially adheres to the site of a retinal tear. Also provided herein are methods of treating retinal detachment by delivering an in vivo gelling ophthalmic pre-formulation to the site of a retinal tear in human eye, wherein the in vivo gelling ophthalmic pre-formulation forms a retinal patch.