Two good methods,
[ul]
[li]Use pipe loops, per B31.1 or B31.3 correctly designed, longest lasting, least chance of leaks.[/li]
[li]Use metal bellows, or short lengths of metal hose.[/li][/ul]
Use this search term "bellows expansion joint design" for bellows joints.
Use this search term "expansion loop design guide" for expansion loops, or use code calc software.