The profinite completion of the fundamental group of a closed, orientable $3$-manifold determines the Kneser--Milnor decomposition. If $M$ is irreducible, then the profinite completion determines the Jaco--Shalen--Johannson decomposition of $M$.