Fuel cell
Since spaceships are launched using rockets containing pure hydrogen and oxygen, the on-board electricity is produced using very efficient fuel cells which can use these fuels. Additionally, the fuel cells on spaceships produce pure water on their exhaust, which can be further captured and used as drinking water for astronauts, meaning absolutely nothing is wasted.