IF worried about sagging, use the Sagulator (sagging calculator) as found online... Consider it makes a large difference whether your shelves are loose-laid on top of something bearing them, or screwed fixed (with pocket screws, naturally). [The aim of the sagulator is to get you optically flat shelves, less distorted than visible.] Screwed fixed is great if you know long-term you're right; loose is great if you need to reorder to different heights.
The idea that you need shelves of various depths and widths is something to keep in mind. My corner pantry (cobbled together from three hanging IKEA corner units, heights 2x 60cm 1x 80cm = 200cm seamlessly fitting with the rest, just add the same legs) so there'd be 3 "full" shelves. Then I've bought extra shelves, collected what contents I'd expect to have in there, made cardboard templates and positioned them at the various intended heights to see how it would practically fit: I've cut those extra shelves into a sort of U-shapes, narrow arms and wider at the 'bottom' bit of the U, with jigsaw+router, then steamed on the usual white 'formica' edging.
Different heights have different reachability and safety (dropping stuff!): Highest one is just 2.5inch wide. The middle shelf contains the coffee maker, so its surrounded by a self-made shelf for various coffees and cups and cocoas and chocolates. Above it 5--10 breakfast cereal varieties in the central part, jams/honeys/... surrounding it. Heavy lumpy things (sugars, flours, baking stuff, ... ) below it. So heavy things don't sit on the narrow self-cut shelves, but on the "full planks" below them.
[If anybody runs with this idea: Caveat is that you can insert a shelf into a finished unit if it's 80cm high; the 60cm units it cannot enter & rotate flat, you must disassemble the unit. Or cut your new shelf in two. This being modular it means it's loose-shelves-so-height-adjustable.]