According to New Hampshire law, a person is prohibited from possessing firearms if they have been "adjudicated mentally defective or insane." This means that if a court has found you to be mentally incompetent or unable to manage your own affairs, you are not allowed to own firearms.
A commitment to a mental institution is evidence that you have been deemed to be mentally defective or insane. As a result, you would be prohibited from owning firearms in New Hampshire.