BACKGROUND: Opioid use disorder (OUD) in pregnancy has substantially increased throughout the drug overdose crisis, but little is known about how local community environments are associated with OUD in pregnancy. This study investigates spatial patterns and residential ZIP code-level factors associated with delivery hospitalizations with OUD in Pennsylvania and compares these patterns to those for all delivery hospitalizations and all OUD-related hospitalizations. METHODS: ZIP code-level inpatient hospitalizations based on patients' residential ZIP codes in Pennsylvania were examined from 2016 to 2019. Using Bayesian hierarchical space-time conditional autoregressive models, we assessed the contributions of residential ZIP code-level factors to OUD delivery hospitalizations and compared these associations to those from models of all delivery hospitalizations and all OUD-related hospitalizations. RESULTS: Significant spatial autocorrelation was identified for all three types of hospitalizations. Higher unemployment, greater population density, higher overall hospitalization rate, and presence of an OUD treatment facility were associated with greater OUD delivery hospitalizations in residential ZIP codes, while higher median household income and a greater proportion of the population who were non-Hispanic Black and Hispanic were associated with lower OUD delivery hospitalizations. Findings were similar to those for all OUD-related hospitalizations. The effect of ZIP code-level unemployment rate differed between all delivery hospitalizations and those with OUD, with a positive association with OUD deliveries and a negative association with all deliveries. CONCLUSIONS: Areas with worse economic conditions and greater population density are associated with OUD at delivery, similar to all OUD-related hospitalizations. Community OUD programs may consider simultaneously targeting OUD concerns in pregnancy.