In a saucepan, combine the sugar and water.
Cook over medium heat, stirring constantly until the sugar is dissolved and the mixture starts to boil.
Continue to cook until the syrup thickens slightly, about 5 minutes.
Add the butter, cinnamon, and nutmeg to the syrup. Stir until the butter is melted and well incorporated.
Stir in the grated coconut and vanilla extract.
Cook the mixture over low heat, stirring constantly, until the coconut is fully coated and the mixture becomes thick and starts to pull away from the sides of the pan, about 10 minutes.
Transfer the mixture to a greased baking dish or a parchment-lined tray.
Press it down evenly with the back of a spoon or spatula to compact it.
Let it cool completely before cutting into squares or bars.
Enjoy as a sweet treat or dessert.
Enjoy your meal!