Whisk together the heavy cream, milk, and erythritol in a saucepan then bring to a boil.
Cook on medium-low heat until reduced by half – about 1 hour.
Stir in the butter and xanthan gum, then remove from heat.
Preheat the oven to 325°F and grease 4 ramekins with butter or coconut oil.
Beat the eggs until frothy, then beat in the cream mixture along with the coconut milk, shredded coconut, and vanilla.
Adjust sweetness to taste, then divide among the four ramekins.
Bake for 50 to 60 minutes until the tops of the flans are lightly browned.
Cover with plastic and chill until ready to serve.