In this paper, we report on a rechargeable lithium battery based on a single hexagonal tungsten oxide (h-WO3) nanowire. This nanobattery can discharge at a voltage of 0.27–0.1V and a current of 20–10pA for more than 1000s with a capacity of 15.2nC, suggesting that each WO3 molecule could accommodate 1.8–2.2 Li+ ions on average. It exhibits excellent stability and repeatability. Real time ultraviolet (UV) light detection is achieved through a single WO3 nanowire based UV sensor, which is powered by the nanobattery.