The electronic, optical, and magnetic properties of graphene nanoribbons (GNRs) can be engineered by controlling their edge structure and width with atomic precision through bottom-up fabrication based on molecular precursors. This approach offers a unique platform for all-carbon electronic devices but requires careful optimization of the growth conditions to match structural requirements for successful device integration, with GNR length being the most critical parameter. In this work, the growth, characterization, and device integration of 5-atom wide armchair GNRs (5-AGNRs) are studied, which are expected to have an optimal bandgap as active material in switching devices. 5-AGNRs are obtained via on-surface synthesis under ultrahigh vacuum conditions from Br- and I-substituted precursors. It is shown that the use of I-substituted precursors and the optimization of the initial precursor coverage quintupled the average 5-AGNR length. This significant length increase allowed the integration of 5-AGNRs into devices and the realization of the first field-effect transistor based on narrow bandgap AGNRs that shows switching behavior at room temperature. The study highlights that the optimized growth protocols can successfully bridge between the sub-nanometer scale, where atomic precision is needed to control the electronic properties, and the scale of tens of nanometers relevant for successful device integration of GNRs.