Baby ducks eat mostly invertebrates for the first few weeks of their lives, including insects, worms, snails and crustaceans. They need a huge amount of high-protein food for these first few weeks, and as soon as the ducklings hatch, the mother will usually take them to wherever there is the most food.
As they are born with part of the egg yolk still inside them in an egg sack, baby ducks can survive for approximately the first three days of life without eating. Ducks mature incredibly quickly, so by the time they are two or three weeks old, they will already begin eating like normal adult ducks. For some species, this means switching over to eating primarily plants or possibly nuts and seeds.
Domesticated ducklings also have the same high fat and protein nutritional requirements as their wild counterparts. However, they are usually supplied this in the form of specialized duckling food that can be found in pet stores. It is also possible to feed them food designed for baby chickens, but it's necessary to increase the niacin content of this food, such as with brewer's yeast. Some people also recommend slowly adding oats to their diet as well.
Ducks require bits of rock and dirt in their stomach to properly digest food, so it's also important to take a small amount of gritty dirt or buy chick grit and mix this into the duckling's food.