  Ultracool dwarfs (UCD; $T_{\rm eff}<\sim3000~$K) cool to settle on the main
sequence after $\sim$1 Gyr. For brown dwarfs, this cooling never stops. Their
habitable zone (HZ) thus sweeps inward at least during the first Gyr of their
lives. Assuming they possess water, planets found in the HZ of UCDs have
experienced a runaway greenhouse phase too hot for liquid water prior to
entering the HZ. It has been proposed that such planets are desiccated by this
hot early phase and enter the HZ as dry worlds. Here we model the water loss
during this pre-HZ hot phase taking into account recent upper limits on the XUV
emission of UCDs and using 1D radiation-hydrodynamic simulations. We address
the whole range of UCDs but also focus on the planets recently found around the
$0.08~M_\odot$ dwarf TRAPPIST-1.
  Despite assumptions maximizing the FUV-photolysis of water and the XUV-driven
escape of hydrogen, we find that planets can retain significant amounts of
water in the HZ of UCDs, with a sweet spot in the $0.04$-$0.06~M_\odot$ range.
We also studied the TRAPPIST-1 system using observed constraints on the
XUV-flux. We find that TRAPPIST-1b and c may have lost as much as 15 Earth
Oceans and planet d -- which might be inside the HZ -- may have lost less than
1 Earth Ocean. Depending on their initial water contents, they could have
enough water to remain habitable. TRAPPIST-1 planets are key targets for
atmospheric characterization and could provide strong constraints on the water
erosion around UCDs.
