In device-independent quantum key distribution (DIQKD), the violation of a Bell inequality is exploited to establish a shared key that is secure independently of the internal workings of the QKD devices. An experimental implementation of DIQKD, however, is still awaited, since hitherto all optical Bell tests are subject to the detection loophole, making the protocol unsecured. In particular, photon losses in the quantum channel represent a fundamental limitation for DIQKD. Here, we introduce a heralded qubit amplifier based on single-photon sources and linear optics that provides a realistic solution to overcome the problem of channel losses in Bell tests.