A hydrogel electrolyte is prepared with quaternary ammonium side chain chitosan (N-CS) and polyvinyl alcohol as the main chain. N-CS and polyvinyl alcohol form a highly cross-linked network through hydrogen bonding. At the same time, the gel also has excellent sensing performance, and then we select the activated carbon electrode with good compatibility with chitosan to assemble the devices. The electrochemical window of the assembled device can reach 1.6 V, and the maximum energy density is as high as 10.03 Wh kg−1. After 5000 charge/discharge cycles, the capacitance retention rate of the supercapacitor device is 92.5% at temperature of room. Moreover, the gel shows outstanding sensing ability, the sensing factor is 0.995, the response time is 180 ms, and such performance can still be maintained after multiple cycles.