We present a non-perturbative renormalization-group approach to the Bose-Hubbard model. By taking as initial condition of the RG flow the (local) limit of decoupled sites, we take into account both local and long-distance fluctuations in a nontrivial way. This approach yields a phase diagram in very good quantitative agreement with the quantum Monte Carlo results and reproduces the two universality classes of the superfluid--Mott-insulator transition with a good estimate of the critical exponents. Furthermore, it reveals the crucial role of the Ginzburg length as a crossover length between a weakly- and a strongly-correlated superfluid phase.