I put pine bark shreds on top of my seed-starting trays to keep the surface dry. I've never had gnats but I don't know whether the bark helped or maybe "I just don't have gnats". Wouldn't you think gnats could crawl under the bark layer to reach the moist mix?
I also avoid organic fertilizer and compost in my seedling trays. If your potting mix has organic components that decompose in the pot, that may be growing small amounts of fungus, hence attracting fungus gnats. The next time you re-pot, you might consider an indoor mix that is less prone to fungus, and drains fast enough to especially discourage fungus on the surface.
You might scraper an inch of mix off the top, and discard that along with any insect eggs. Then replace the top layer with something less organic and faster-draining.
If you do try peroxide, first test whether DILUTE peroxide is enough to discourage them.
Like 2 ounces of drugstore peroxide per quart of water. Or one cup per gallon. That gives a final strength of 0.2% peroxide.
(Drugstore hydrogen peroxide bottles have 3%. Food Service peroxide might be 20%.)