For the 2021 Trek Rail 9 XL specifically, frame bags are a bit of a puzzle because of the integrated battery and the size of the main triangle on an XL frame.
Frame bag
The
WILDMAN (AliExpress) is the community go-to — cheap, surprisingly well made, and available in sizes that work around the battery housing. Worth trying before spending more. The
LEEDS frame bag is another solid option and has been confirmed on XL frames with enough volume to carry a spare battery alongside trail essentials.
If the standard options don't quite fit your junction geometry, a custom bag from an Etsy maker is often the only thing that clears both the down tube and leaves room for a bottle underneath.
Handlebar / bottle storage
Honest take: true bar bags on an eMTB are more trouble than they're worth — weight up high and cable fouling at full lock. A
Fidlock 750ml magnetic bottle stays put on rough trails without rattling.
@PetrD confirmed the Specialized Zee Cage II with side-opening bottle access works well on a Trek Rail XL — tools integrated, no bar clutter.
For tube and plug duty, a small saddle bag beats anything dangling off the bars.
My pick: WILDMAN frame bag + Fidlock 750ml + small saddle bag for tools. Covers 90% of rides. Are you carrying a range extender, or just trail essentials? That changes which frame bag size to go for.