Build an industry selector for business onboarding
Search US NAICS 2022 titles with Node.js and keep the code and title a person selects in your onboarding form.
Working example
ParseAPISet up ParseAPI
Set PARSEAPI_KEY in your server environment. Use Node.js 22 or later.
export PARSEAPI_KEY='YOUR_SECRET_API_KEY'Let a business choose its industry
Add an industry choice to a business onboarding form. Someone describes what the business does, reviews matching US NAICS 2022 titles, and selects the one that fits. Keep the selected code, title, country, and revision together.
This Node app keeps the secret key on the server and renders the choices in a normal browser form. Industry search has no Form.js preset, so the server calls the Industry API directly.
1. Search the stated activity
Read the activity description or code from your form. Pass it to Industry search:
const industries = await parse.industry.search(query, { limit: 6, signal });industries.results contains matching records. Use naics for the code and name for the title. The envelope supplies country: "US" and year: 2022 for the results. level identifies the classification depth, from a broad sector to a six-digit US industry.
The complete app accepts 2-100 characters and requests six choices per search. The server checks the returned country, revision, and record types before presenting them. An unavailable search remains a request error, not a claim that no industry matches.
2. Present the code beside its title
Build a button for each result:
for (const industry of industries.results) {
const item = document.createElement('li'), button = document.createElement('button');
const title = document.createElement('strong'), code = document.createElement('span');
button.type = 'button'; title.textContent = industry.name;
code.textContent = industry.naics + (industry.level < 6 ? ' · Broad classification' : ' · US industry');
button.append(title, code); button.addEventListener('click', () => choose(industry, industries));
item.append(button); results.append(item);
}The code helps distinguish similar titles. Broad results are labeled so the person can search more specifically when needed. Native buttons support keyboard selection. No result is selected automatically.
Searching by an activity is useful evidence for a person to review. It does not establish what a particular company does or decide its classification for a legal purpose.
3. Keep the confirmed choice with the form
When the person chooses a title, fill the fields your application will submit:
document.querySelector('#naics').value = industry.naics;
document.querySelector('#industry-name').value = industry.name;
document.querySelector('#industry-country').value = scope.country;
document.querySelector('#industry-year').value = String(scope.year);Treat naics as a string. Store its US country and 2022 revision with it so another part of the app can interpret the code later. Show the chosen title beside those details.
The complete app also emits an industrychange event from the form with that selected code, name, country, and year. Your existing onboarding code can consume those fields or handle the event. Editing the activity clears the old choice, so it cannot silently remain attached to a different description.
4. Recheck the choice when your app saves
Hidden inputs are still browser input. On your existing server-side save path, look up the submitted code with Industry and check its country and revision before storing the accepted selection. Keep the person's confirmation as part of your onboarding flow.
The example searches only on submit. Changing the activity cancels a pending search and clears its choices, and late answers cannot restore them. The server gives the request eight seconds and leaves retrying to the person using the form. See the Industry reference for code lookup, hierarchy and search behavior.
Complete example
Use the complete implementation as a reference when adding this feature to your app. It includes the validation and failure handling around the calls above.
View and copy the complete source
Try the complete example on your computer
After completing the setup above, save the source in your application folder and start the app:
node industry-selector.node.mjsOpen 127.0.0.1:8000 to use the form. The server keeps your secret key out of the page.
For every field and parameter, see Industry API reference.