Apple cider vinegar works well.
Watch what veggies you bring in the house. I bought a live bunch of Basil, the kind with a root ball, and it was infested with fruit flies just waiting to hatch in my kitchen. Was a freaking nightmare getting rid of them. I could barely eat at my kitchen table they were so bad. Also, make sure everything in your kitchen is dry (no leaks, no moisture under the sink or around the dishwasher etc.). Even your sponge can become a breeding ground. An adult female fruit fly can lay up to 2,000 eggs on the surface of anything that's moist and rotting. Within 30 hours, tiny maggots hatch.