ImportanceGestational exposure to nonsteroidal anti-inflammatory drugs (NSAIDs) may increase the risk of adverse fetal kidney outcomes. However, details regarding timing, specific NSAIDs, and long-term childhood kidney outcomes are limited.ObjectiveTo evaluate the association between gestational exposure to NSAIDs and the risk of chronic kidney disease (CKD) in childhood.Design, Setting, and ParticipantsThis national cohort study assessed 1 025 255 children born alive in Taiwan from January 1, 2007, to December 31, 2017, with follow-up until December 31, 2021. Children without valid maternal-child linkage and with incomplete birth information were excluded. Data analysis was performed from November 30, 2023, to April 30, 2024.ExposureMaternal prescriptions for NSAIDs from the last menstrual period to birth.Main Outcomes and MeasuresThe main outcome was childhood CKD, including congenital anomalies of the kidney and urinary tract and other kidney diseases. Cox proportional hazards regression models with stabilized inverse probability of treatment weighting (weighted hazard ratio [wHR]) and a robust sandwich estimator were used to estimate the relative risk of NSAID exposure in pregnancy, adjusted for newborn characteristics.ResultsThis study included 163 516 singleton-born children (24.0%) whose mothers (mean [SD] age at birth of child, 31.25 [4.92] years) used at least 1 dispensing of an NSAID during pregnancy. Gestational NSAID exposure was significantly associated with a higher risk of childhood CKD (wHR, 1.10; 95% CI, 1.05-1.15). No association was observed between NSAID use and fetal nephrotoxicity in sibling comparisons. Elevated risks were revealed for exposure during the second trimester (wHR, 1.19; 95% CI, 1.11-1.28) and the third trimester (wHR, 1.12; 95% CI, 1.03-1.22) in singleton-born children. Specific NSAID exposures associated with higher CKD risk included indomethacin (wHR, 1.69; 95% CI, 1.10-2.60) and ketorolac (wHR, 1.28; 95% CI, 1.01-1.62) in the first trimester, diclofenac (wHR, 1.27; 95% CI, 1.13-1.42) and mefenamic acid (wHR, 1.29; 95% CI, 1.15-1.46) in the second trimester, and ibuprofen (wHR, 1.34; 95% CI, 1.07-1.68) in the third trimester.Conclusions and RelevanceIn this study, gestational exposure to NSAIDs was not associated with a substantial increase in the risk of childhood CKD when comparing between siblings. However, the findings underscore the need for caution when prescribing NSAIDs during pregnancy, particularly indomethacin and ketorolac in the first trimester, mefenamic acid and diclofenac in the second trimester, and ibuprofen in the third trimester, to ensure the safety of the offspring’s kidneys.