Ab initio calculations of nuclear widths via an integral relation