Start by trimming the green beans and slicing the onions thinly. I find that uniform slices cook more evenly and caramelize nicely. Make sure the beans are dry so they roast instead of steam.
Heat olive oil in a skillet over medium-high heat. Add onions with a pinch of salt, stir occasionally, and lower the heat after 10 minutes. Cook slowly for 30 minutes until they turn golden brown and sweet.
Toss green beans with a little olive oil, salt, and pepper on a baking sheet. Roast in a preheated oven at 425°F (220°C) for 20–25 minutes until slightly charred. I like to stir halfway for even roasting.
Once the beans are roasted, mix them gently with caramelized onions. Taste and adjust salt or pepper as needed. Serve warm for the best flavor and texture.