This is a really unpleasant situation. It is not that probable to happen but, just in case it does, you should be prepared. Who knows? Maybe you will save someone’s life, family or car.
First of all you have to know where is the fire extinguisher hidden in your car. Then, you should know how reliable it is. You check that by looking at the pressure indicator. It should be in the green area. If not, buy another one or refill that one.
Second of all, you should know what kind of fire extinguisher you have. The best ones for an automotive fire are the ones with powder but you can have also a CO2 extinguisher. In order to use it, pull the safety nail, aim it at the fire source, press hard and hold the lever until the fire extinguisher is empty or the fire is out. You should do a bit of training for this situation. Get out of the car as fast as you can, find the fire extinguisher and go to an imaginary fire source and try to stop it. My advice is to use at least once a fire extinguisher just to know how it works and how it is better to use it. This can be a fun and useful exercise to do with your friends.
Now that you know how to stop a fire, you should know how to detect one and how to react better. The most probable type of fire to start in a car is an electrical fire. The most probable area is the engine compartment. If you saw a strange smoke coming from under the hood but the engine temperature is within parameters your car may have caught fire. First of all, DON’T PANIC! As fast as you can pull the car on the side of the road, stop the engine, take the fire extinguisher, open the hood and try to stop the fire. If this doesn’t work, get as far back from the car as possible and wait for help. Don’t try to save anything from the car. Automotive fires spread quickly and you shouldn’t risk anything. That’s why you have insurance for.
The most important advice I can give in such a situation is to try not to panic and to think as objective as you can. It is more important to save yourself and other persons in the car.