The objective was to evaluate effects of niacin on the intestinal epithelial barrier, intestinal immunity, and microbial community in weaned piglets challenged by Porcine Deltacoronavirus (PDCoV). In this study, fifteen weaned piglets were randomly assigned to 1 of 3 groups, (1) control group, normal diet; (2) PDCoV group, infected with 1 × 107 TCID50 of the PDCoV CHN-HN-17 strain by oral administration; (3) NA + PDCoV group, infected with 1 × 107 TCID50 of the PDCoV CHN-HN-17 strain by oral administration following administration of 40 mg of niacin for three days. The results showed that PDCoV infection induced diarrhea and other clinical symptoms with intestinal villi shedding and atrophy in weaned piglets. Niacin alleviated the symptoms of diarrhea and intestinal damage of PDCoV-infected weaned piglets. Additionally, PDCoV increased (P < 0.05) the mRNA expression of tight junction proteins [zonula occludens-1 (ZO-1) and Claudin] and antimicrobial peptides [porcine β defensin 1 (pBD1), pBD2, proline-arginine rich 39-amino acid peptide (PR39) and protegrin 1-5 (PG1-5) in the jejunum and ileum of weaned piglets, while niacin increased (P < 0.05) the expression of PG1-5 compared with PDCoV. PDCoV increased (P < 0.05) the contents of serum interleukin-1β (IL-1β), IL-8 and intestinal IL-8, and up-regulated the mRNA expression of tumor necrosis factor-α (TNF-α), IL-1β, IL-6, IL-10, IL-12, and IL-18 in ileum of weaned piglets compared with control. However, niacin decreased (P < 0.05) the contents of serum IL-1β, IL-6 and intestinal IL-10 and IL-8, and also reduced (P < 0.05) the mRNA expression of ileal TNF-α, IL-10 and IL-12 in the PDCoV-infected piglets. Compared with control, PDCoV up-regulated (P < 0.05) the mRNA expression of key genes related to innate immune and antiviral molecules [toll-like receptor 4 (TLR4), NOD1, NOD2, DDX58, CCL2, STAT2, Mx1, IFN-γ, and protein kinase R (PKR) in the ileum of weaned piglets. Niacin decreased (P < 0.05) the mRNA expression of NOD1, NOD2, STAT2, IFN-γ, and PKR in PDCoV-infected weaned piglets. Moreover, the mRNA expression of IL-6 decreased (P < 0.05) and 2'-5'-oligoadenylate synthetase (OAS), IFN-α, and PKR increased (P < 0.05) in PDCoV-infected IPEC-J2 cells treated with niacin in vitro. Furthermore, niacin decreased (P < 0.05) the elevation of protein expression including inducible NOS (iNOS), nuclear factor-κB (NF-κB p65), inhibitor kappa B (IKKβ), histone deacetylase [Sirtuin 1 (SIRT1) and histone deacetylase 7 (HDAC7) and phosphorylation of histone H3 at serine s10 (pH3s10) in the ileum of PDCoV-infected piglets, and increased (P < 0.05) the expression of G protein-coupled receptor (GPR109A). PDCoV disrupted the composition and structure of microflora in the colon of weaned piglets, and reduced the relative abundance of the beneficial bacteria Spirobacterium, but niacin could improve the intestinal microbial flora of the PDCoV-infected piglets associated with increasing the relative abundance of Lactobacillus. Overall, niacin could alleviate diarrhea, intestinal barrier damages, intestinal immune response and colonic microflora disfunction in PDCoV-infected weaned piglets.