Few people foresaw how quickly fentanyl would displace heroin, doubling or tripling opioid overdose deaths in some pockets of the United States from 2013 to 2017. But we could have been warned—if only we’d checked our wastewater.

Today there is growing concern over a resurgence in methamphetamine use, as overdose deaths involving meth are at record levels. To respond rapidly to a crisis in its early stages, we need real-time warnings when drug use patterns are shifting.

Right now, our measures are too slow. State and federal agencies analyze surveys of individuals, drug seizure data from law enforcement, and medical records related to overdoses. Each method is useful but has its shortcomings. People may report their own drug use inaccurately on surveys because of the stigma of using heroin or methamphetamine—or because their dealers sold them fentanyl as heroin or meth as ecstasy. Toxicology tests after an overdose death or chemical analysis of seized drugs are more accurate but they’re also expensive and time-consuming—if they’re performed at all.

And there’s a long lag before results are available. The most current national data on overdose deaths and drug seizures are from 2018. Imprecise and slow data mean that police, public health officials, researchers and drug users don’t know what risks are lurking until it’s too late.

Wastewater testing could change that.

When an individual takes a drug, the body metabolizes it and excretes metabolites. Just as urine tests detect these metabolites for individuals, wastewater testing can reveal what drugs are being used in a city or region in the aggregate. Routine tests done at local water treatment facilities could indicate, as just one example, whether marijuana consumption had increased significantly after legalization—but it wouldn’t pinpoint particular neighborhoods, households or individuals.

This approach already is being applied in Australia and Europe to understand drug consumption patterns and to spot changes. In European cities, water analyses are sophisticated enough to discern use in real time, showing the uptick of cocaine and ecstasy use on the weekends. In the U.S., paired with drug use surveys and law enforcement seizures, wastewater drug analysis would provide a detailed understanding of the markets for illegal drugs and how they are evolving.

Wastewater testing has another advantage: it’s fast and relatively cheap. Utilities and public health agencies already run routine tests on wastewater for pathogens, pharmaceuticals, and a wide range of pollutants. Drug metabolite analysis could be added to these protocols at minimal expense. A 2017 study from the consulting firm Mathematica estimated that the cost could be as low as $100 per sample.

For comparison, the federal government spends close to $50 million annually on household surveys to estimate the prevalence of drug use nationwide. For less than 10 percent of that, wastewater in hundreds of cities could be analyzed multiple times every week.

This doesn’t mean household surveys should be abandoned. Surveys can tell us how frequently people take a drug and what methods they use. Wastewater testing also can’t capture market changes in rural communities where individual household septic systems are far more common than community wastewater collection and treatment plants. But wastewater testing would provide real-time insights into emerging drug threats in urban and suburban areas.

Some cities in Washington and Oregon have tested wastewater to get a read on local drug use, but not in a standardized way. To gain the kind of insights and early warnings that Australia and Europe have, the United States needs a well-designed (and funded) national pilot program that includes geographic and socioeconomic diversity.

Imagine if a city not yet swamped by fentanyl had adopted wastewater testing. A spike in detected metabolites could have given everyone early warning. Law enforcement could have been on the lookout for suppliers. Public health authorities might have optimized the distribution of naloxone. Social workers might have warned drug users about the risks of heroin laced with fentanyl. Many lives might have been saved.

This hypothetical could become reality if the United States chooses to invest in accurate, real-time drug detection.