Add the milk to a nonstick saucepan, along with the vanilla. If using a vanilla pod, cut the bean lengthways and scrape out the seeds with a knife. Also add the vanilla bean pod to the milk to infuse for maximum flavour. Heat over low-medium low heat, until it gets to a simmer, but not quite boiling.
While the milk heats up, combine the egg yolks and sugar in a medium bowl. Use a hand mixer or a whisk to beat the egg yolks until frothy and pale. Mix in the cornstarch in two stages, making sure it's fully incorporated into the eggy mixture.
Once the milk is bubbling hot, gently pour ¼ of it over the eggs, whilst whisking the mixture continuously. Mixing prevents lumps from forming, ensuring you get a silky smooth pastry cream.
Pour the egg mixture back in with the rest of the milk, whisking vigorously to incorporate it well. Place the saucepan back over medium heat to cook the pastry cream, whilst mixing continuously. Ensure you keep a close eye on the pastry cream and keep mixing, to prevent lumps from forming. Cooking the pastry cream ensures the eggs are safe for consumption, but also thickens the cream.
We need to bring the pastry cream to boiling temperature. Once it starts to bubble and thicken, reduce the heat and cook for another 1-2 minutes. After this, take the mixture off the heat and mix in the butter. Mix it in properly until it's fully melted into the cream. Pour the hot pastry cream into a bowl, then cover with plastic wrap. Ensure the plastic film touches the entire surface of the pastry cream, to prevent a skin from forming. Watch your fingers because it is hot!
Let the pastry cream cool down at room temperature for half an hour, then pop it in the fridge for at least 2 hours. Before using, whisk it vigorously or use a hand mixer to make the cream super smooth and silky.
Notes
I recommend using a kitchen scale in grams for more accuracy. The cups used for the conversion are standard US customary cups (1 cup flour = 136g). There are many different types of cups across the globe, which is why I strongly recommend using grams instead.
If you want a slightly runnier pastry cream (for pouring), use 20-25g of corn starch instead.
Corn starch can be replaced with flour, just double the quantity (25g corn starch = 50g flour).
You can also use vanilla extract, but it needs to be added at the end with the butter. Adding it before the cooking process will make the flavour less intense.