01 - Heat oil in a large skillet over medium-low heat. Add sliced onions and a pinch of salt. Cook, stirring occasionally, for 20–25 minutes until golden and deeply caramelized. Add sugar halfway through if desired for extra sweetness. Remove from heat and set aside.
02 - While onions cook, combine rinsed rice, coconut milk, water, grated ginger, lime zest, and salt in a medium saucepan. Stir well and bring to a gentle boil over medium heat.
03 - Reduce heat to low, cover, and simmer for 15–18 minutes, or until the rice is tender and liquid is absorbed. Remove from heat and let stand, covered, for 5 minutes.
04 - Fluff the rice with a fork. Stir in lime juice and half the chopped herbs.
05 - Transfer rice to a serving dish. Top with caramelized onions, remaining herbs, and toasted coconut flakes if using. Finish with a few grinds of black pepper. Serve warm as a side or light main.