Campervans can get power in several ways, including batteries, solar panels, generators, shore power or through the van's alternator.
Here's a run down of these different power options:
Batteries: Most campervans have a deep-cycle battery or a bank of batteries installed to power lights, appliances, and other electrical devices. These batteries can be recharged using solar panels, the van's alternator, a generator, or by plugging into an external power source.
Solar panels: Solar panels can be installed on the roof of a campervan to generate electricity from the sun. This energy can be used to power appliances and devices or recharge the van's batteries. For a portable setups, solar power generators with folding solar panel briefcases are also an option.
Generator: A generator can be used to power a campervan when an external power source is not available. Generators can run on gasoline, propane, or diesel fuel and can be portable or built-in.
Shore power: Shore power allows you to plug your van into a power outlet at a campsite or RV park.
Alternator: The vehicle's alternator can be used to charge the battery or batteries while the vehicle is running.
Typically, most campervans combine a few different power options to cover a wider range of use cases and power needs. Solar panels + charging the batteries from the vehicle's alternator is generally the most common approach used, since it provides enough power for most use-cases and works well in off-grid situations.
If you are just getting into vanlife and are unsure about how you are going to use your van, consider buying a portable solar generator instead. These charge from the 12v outlet of your van (and via optional solar panels) and are a great low cost, plug and play solution.