You can do a few things to prevent your cupcakes from sinking. First, make sure you follow the recipe closely and don't overmix the batter. Be careful not to open the oven door too often while they're baking, and let them cool completely before removing them from the pan.