We have visited Hanoi in early June. We were pretty lucky with the weather, never about 95 degrees and it only rained twice, both times pretty quick thunderstorms. Both Sapa and Nimh Binh area were easy trips and much cooler.
The flight from Hanoi to Bali is more than 7 hours so I would stay with one country or look at nearby options.
Another option is to fly to SIN and hop on quick flight to Yogyakarta and then Bali or Bali and the beaches.