In maintaining organismal homeostasis, gut immunity plays a crucial role. The coordination between the microbiota and the immune system through bidirectional interactions regulates the impact of microorganisms on the host. Our research focused on understanding the relationship between substantial changes in jejunal intestinal flora and metabolites and intestinal immunity during porcine epidemic diarrhea virus (PEDV) infection in piglets. We discovered thatLactobacillus rhamnosus GG(LGG) could effectively prevent PEDV infection in piglets. Further investigation revealed thatLGGmetabolites interact with type 3 innate lymphoid cells (ILC3) in the jejunum of piglets through the aryl hydrocarbon receptor (AhR). This interaction promotes the activation of ILC3 cells and the production of interleukin-22 (IL-22). Subsequently, IL-22 facilitates the proliferation of IPEC-J2 cells and activates the STAT3 signaling pathway, thereby preventing PEDV infection. Moreover, the AhR receptor exerts its influence on various cell types within organoids, including intestinal stem cells (ISCs), Paneth cells, and enterocytes, fostering their growth and development, suggesting a broad impact of AhR on intestinal health. In conclusion, our study demonstrates the ability ofLGGto modulate intestinal immunity and effectively prevent PEDV infection in piglets. These findings highlight the potential application ofLGGas a preventive measure against viral infections in livestock.