Optimizing stimulation protocols for peripheral neuromodulation often depends on patient feedback, which can result in inconsistent clinical outcomes. Here we present a closed-loop control system for peripheral nerve stimulation (PNS) that utilizes evoked compound action potential (ECAP) feedback to regulate stimulation parameters, addressing the limitations of traditional methods. Unlike established closed-loop control techniques in the central nervous system, such as local field potential and spike analysis, a comparable approach for the peripheral nervous system remains underdeveloped. ECAPs can be consistently observed across peripheral nerves, providing a reliable measure of nerve activation. We developed a fully implantable device and neural interface for tibial nerve stimulation (TNS) that incorporates the proposed closed-loop system. This TNS system shows promise as a PNS treatment for alleviating overactive bladder symptoms. In a rat model, the system demonstrated longer micturition intervals and greater effectiveness compared to conventional motor response-based control.