Keep it Cool, Dark and Dry
You probably already know to store onions in a cool, dark, dry place. Moisture is one of the biggest reasons onions go bad. Hanging them in a mesh bag will help them breathe. Ideally, place one onion in the bag, then tie off the space with a twist tie. Insert another onion and repeat. This keeps the onions from touching each other and allows any moisture to evaporate. You can also use pantyhose if you don't have a mesh bag.
A wire basket in a pantry or lower cabinet is also a good choice. Although you will need to rotate the onions to ensure they stay dry if you plan to store them for long periods of time.
If you use onions a lot or tend to stock up on them at the farmers market, you may want to consider freezing them. Chop them as fine as you like and spread on a cookie sheet. Freeze for one hour, then transfer to a zipper bag or airtight jar and return to the freezer. That way all the pieces freeze separately and they can be poured out of the bag or jar as needed.
Freezing is also an Option
You can also puree the onions and freeze them in ice cube trays. Once the cubes are frozen, they can be stored in a freezer bag or airtight jar.
Whatever You Do, Don't Do These Three Things
You may NOT know that you should never store onions in the refrigerator for an extended time as the cold will make them slightly soft. Onions should also never be stored with potatoes as this accelerates the spoilage of them both. Don't use plastic bags either as they hamper air circulation, and make onions sprout and spoil faster.