Heat oil in a large saucepan or deep frying pan over medium heat. Add onion and cook for about 5 minutes, until softened.
Add massaman curry paste and cook, stirring, for 1 to 2 minutes until fragrant. Add chicken and stir well to coat, cooking for another 2 minutes to lightly seal.
Add star anise, cinnamon stick, red chilli, and kaffir lime leaves. Cook for 1 minute, stirring, until aromatic.
Pour in coconut milk or cream and chicken stock. Add potatoes, carrots, brown sugar, and fish sauce. Stir well to combine. Bring to a gentle simmer, then reduce heat to medium-low. Cook for 40 to 45 minutes, stirring occasionally, until the chicken is cooked through and the vegetables are tender.
Stir through lime juice, if using. Serve with jasmine rice and top with peanuts, fried shallots, extra chilli, and Thai basil or coriander.