Direct attachment to a joist is ideal for optimal support. However, if this isn’t feasible, consider a fan-rated brace that can span between two joists, providing a sturdy foundation for your fan.