From page 194 of the Player's Handbook:
If the d20 roll for an attack is a 20, the attack hits
regardless of any modifiers or the target’s AC. In
addition, the attack is a critical hit, as explained later
in this chapter.
From page 196 of the Player's Handbook:
When you score a critical hit, you get to roll extra dice for the attack's damage against the target. Roll all of the attack's damage dice twice and add then together. Then add any relevant modifiers as normal.
This applies to all attacks, whether they are melee weapon attacks, ranged weapon attacks, melee spell attacks, ranged spell attacks, etc. If you are rolling a d20 versus AC, then you score a critical hit on a 20, and unless you have a class feature, feat, etc. that says otherwise, you roll damage dice twice when you get a critical hit.