The short answer: You can substitute coconut oil in just about any recipe that calls for butter.
In some cases, especially in baking, the results won't be exactly the same. And coconut oil won't behave exactly the same way butter does when you working with it. But as long as you know what to expect, there won't be any surprises.
Baking with Coconut Oil
Cookies made with coconut oil instead of butter will generally turn out okay, though they'll be a bit more crunchy.
That's because butter is 16 to 17 percent water, while coconut oil is pure fat. Less moisture produces a crisper cookie.
If you wanted to be entirely accurate, you could add some liquid to make up for the missing water. So for every cup of butter (226 grams) in the recipe, substitute 194 grams of coconut oil and 36 grams (or a little over 2 tablespoons) of milk.
Recipes that call for melted butter, like bread, quickbreads, muffins and cakes, will be fine. Just make sure the coconut oil is in its liquid form when you use it. This isn't too difficult. If you've ever kept a jar of coconut oil in your house, you know that it has a lower melting temperature than butter: 77 F, to be exact. That means that on a warm day, it'll turn liquid right there in the jar. (Butter melts at 98.6 F, which, conveniently, is the temperature inside your mouth.)
Coconut Oil in Pie Crusts
Where coconut oil won't substitute quite as well is in flaky pastries and pie crusts.
A flaky crust comes from separate blobs of fat that create layers in the dough. But because its melting point is 77 F, coconut oil will liquefy in even a slightly warm kitchen.
And a liquid won't form lumps. Instead, it will coat the flour and basically be absorbed by it, giving the dough a grainy consistency rather than a lumpy one.
This isn't necessarily a bad thing. Pie dough made this way is called mealy pie dough, and it's very tender and crumbly. It's good for bottom crusts of custard and fruit pies because it's less likely to get soggy. It just won't be flaky.
The other thing about this type of dough is that it's more difficult to work with. Rolling it out and fitting it into your pie pan can be a real pain. That's because the fat shortens the gluten molecules (that's why it's called "shortening"), making the dough crumbly, rather than elastic.
On the other hand, if you keep your kitchen cold, and chill your flour, and your bowl and other utensils, you have a chance of making flaky pie dough with solid coconut oil.
Cooking with Coconut Oil
For ordinary cooking, you can use coconut oil anywhere you'd use butter—like for cooking eggs, making grilled cheese sandwiches, spreading on toast and so forth.
Coconut oil and butter both have a relatively low smoke point of around 350 F, so if you're accustomed to heating up some butter in a pan and sautéeing some vegetables, you can use coconut oil in the same way. If your pan gets too hot, it'll start to smoke, just like butter.
Note that coconut oil won't foam in the pan the way butter does, because as mentioned above, butter contains water but coconut oil doesn't, and it's the water in the butter that foams as it evaporates.
Thus, a good way to check whether the coconut oil is hot enough to sauté with is to test it with a drop of water. A droplet of water should sizzle when the oil is hot enough. Just don't use more than a drop of water to test, or hot fat could spatter.
It's Going to Taste Like Coconut
Finally (and from a culinary standpoint, perhaps crucially), whatever you're making is going to taste like coconut rather than butter. If that's all right with you, you're fine. In desserts, a hint of coconut flavor could be quite nice. Scrambled eggs that taste like coconut might not be for everyone. On the other hand, who knows? Maybe it'll become your signature dish.