Preheat oven to 400°F.
Sauté onions in butter until tender and lightly caramelized, setting some aside for garnish.
Layer half the spätzle, half the onions, and half the cheese in a greased 9×13-inch casserole dish. Repeat with the remaining spätzle, onions, and cheese.
Bake, uncovered, for 15 to 20 minutes, or until the top is bubbly and lightly browned.
Garnish with reserved caramelized onion slices and herbs.