All (Many?) of the IKEA beds and bunks rely on Bolts and Barrel Nuts.
You can pay wildly different prices for the Nuts. When I needed a few to
repair/modify an IKEA bunk bought secondhand they were in boxes of 100 from screwfix at 2p each plus lots of postage or £1.24 EACH in B&Q bagged in singles! I got some for an in between price elsewhere.
For their strongest aligning joints they actually use a double barrel sitting in a single hole, which then takes two bolts spaced by about 40mm. This helps align and strengthen those particular joints. I don't know if you can buy these anywhere though.
Although the barrels will take any suitable metric bolt the official bolts have a wide head which is either slightly raised or flat and almost flush to reduce the scope for people to catch themselves on a normal bolt head while spreading the compressive load on the leg timbers. They also have a recessed hex drive hole in the head for the same reason - no edges. Those aspects are worth bearing in mind if using normal bolts/nuts.