Exposure to environmental chemicals has been shown to rewire development affecting later health status. Quantifying the joint effect of environmental mixtures over time is crucial to determine intervention timing. However, causal interpretation of longitudinal environmental mixture studies encounters challenges. There is no statistical approach that allows simultaneously for time-varying confounding, flexible modeling, and variable selection when examining the effect of multiple, correlated, and time-varying exposures. To address these gaps, we develop a causal inference method, g-BKMR, which enables to estimate nonlinear, non-additive effects of time-varying exposures and time-varying confounders, while also allowing for variable selection. An extensive simulation study shows that g-BKMR outperforms approaches that rely on correct model specification or do not account for time-dependent confounding, especially when correlation across time-varying exposures is high or the exposure-outcome relationship is nonlinear. We apply g-BKMR to quantify the contribution of metal mixtures to cardiovascular disease in the Strong Heart Study, a prospective cohort study of American Indians.