With minimal maintenance and effort, you can expect your mealworms to last 3 to 4 weeks at room temperature. If you'd like to keep them alive for longer, follow the guidelines below.
At room temperature (70-74°F), most mealworms will pupate in about 3 weeks. If nutrition and environmental conditions aren't up to par, the mealworms will die instead of metamorphosizing. Mealworm pupae are off-white and they don't eat or crawl around, but they can wriggle and squirm.
Here, you can see a pile of mealworms compared to two freshly-molted pupae.
Refrigerating your mealworms at 45-50°F will cause them to go dormant. They'll move less, eat less, poop less, and grow less. Dormant mealworms can sometimes survive for up to a year - but 6 to 10 weeks is a more realistic and reliable timeline. Ensure that wherever you store them doesn't dip below 40°F - that kind of cold will kill your bugs.
Improper housing can prematurely kill your mealworms. Overcrowding and excessively deep substrate can cause the bugs to suffocate, overheat, or get crushed. A rectangular tupperware container or a plastic shoebox will work well. Be sure to add ventilation holes at the top!
2" to 4" of bedding is sufficient for keeping mealworms alive and well. If the top of the substrate is at least 6" from the top of the container, they won't be able to crawl out, so you won't need a lid (although it's probably more of a comfort factor when you're storing bugs in the fridge!) If the substrate is over 8" deep, it can crush or suffocate the worms.
To promote their health and longevity, take your mealworms out of the fridge and allow them to stay at room temperature for 24 hours every 7 days. When you do this, add some chunks of carrots, apples, sweet potatoes, or squash. Even though your mealworms are dormant, they're still alive and they need sustenance. Feeding them will not only keep them alive longer, but also maintain their nutritional value for your reptilian pal. As the old adage goes: you are what you eat. Before returning your cup of mealworms to the fridge, remove any uneaten food. It may be buried in the bran or bedding - that's normal.