Then, Nicaragua, as well as Costa Rica, El Salvador, Guatemala and Honduras formed the United Provinces of Central America, but that federation quickly dissolved, and Nicaragua became an independent republic in 1838.