Nutrient limitation is one of the most common triggers of antibiotic tolerance and persistence. Here, we present two microfluidic setups to study how spatial and temporal variation in nutrient availability lead to increased survival of bacteria to antibiotics. The first setup is designed to mimic the growth dynamics of bacteria in spatially structured populations (e.g., biofilms) and can be used to study how spatial gradients in nutrient availability, created by the collective metabolic activity of a population, increase antibiotic tolerance. The second setup captures the dynamics of feast-and-famine cycles that bacteria recurrently encounter in nature, and can be used to study how phenotypic heterogeneity in growth resumption after starvation increases survival of clonal bacterial populations. In both setups, the growth rates and metabolic activity of bacteria can be measured at the single-cell level. This is useful to build a mechanistic understanding of how spatiotemporal variation in nutrient availability triggers bacteria to enter phenotypic states that increase their tolerance to antibiotics.