Optogenetics provide a potential alternative approach to the treatment of chronic pain, in which complex pathology often hampers efficacy of standard pharmacological approaches. Technological advancements in the development of thin, wireless, and mechanically flexible optoelectronic implants offer new routes to control the activity of subsets of neurons and nerve fibers . This study reports a novel and advanced design of battery-free, flexible, and lightweight devices equipped with one or two miniaturized LEDs, which can be individually controlled in real time. Two proof-of-concept experiments in mice demonstrate the feasibility of these devices. First, we show that blue-light devices implanted on top of the lumbar spinal cord can excite channelrhodopsin expressing nociceptors to induce place aversion. Second, we show that nocifensive withdrawal responses can be suppressed by green-light optogenetic (Archaerhodopsin-mediated) inhibition of action potential propagation along the sciatic nerve. One salient feature of these devices is that they can be operated via modern tablets and smartphones without bulky and complex lab instrumentation. In addition to the optical stimulation, the design enables the simultaneously wireless recording of the temperature in proximity of the stimulation area. As such, these devices are primed for translation to human patients with implications in the treatment of neurological and psychiatric conditions far beyond chronic pain syndromes.