Finely chop the onion. Peel the mango, then cut the meat into small chunks. Deseed, then finely chop the chilli.
Put all the ingredients in a heavy-based saucepan and bring to the boil, then gently simmer over a low heat for about 30 minutes, while occasionally stirring. Add a drop of water if it gets too sticky too early.
When you get a sticky, thick jam, turn off the heat and allow it to cool.
When cooled, add a squeeze of lime juice, then spoon it into a sterilized jar or into a bowl, ready to serve.
Store in the refrigerator.