We show that the profinite completions and canonical extensions of bounded distributive lattices and of Boolean algebras coincide. We characterize dual spaces of canonical extensions of bounded distributive lattices and of Heyting algebras in terms of Nachbin order-compactifications. We give the dual description of the profinite completion H of a Heyting algebra H, and characterize the dual space of H. We also give a necessary and sufficient condition for the profinite completion of H to coincide with its canonical extension, and provide a new criterion for a variety V of Heyting algebras to be finitely generated by showing that V is finitely generated if and only if the profinite completion of every member of V coincides with its canonical extension. From this we obtain a new proof of a well-known theorem that every finitely generated variety of Heyting algebras is canonical