JavaScript is the language of the web. That is reality; every major browser supports JavaScript as its main language for developing client-side web applications.
Even if you’re using a different language like TypeScript, in the end, it will be transpiled/compiled to JavaScript to be able to run in the browser.
As a Salesforce Developer, you might already be using JavaScript to create your applications: Lightning Web Components (and Aura Components) are powered by JavaScript.
JavaScript isn’t only for the browser, you can also use it to build server-side applications like web APIs, microservices, and CLI applications (like the Salesforce CLI and Heroku CLI). This is thanks to Node.js.
In addition, JavaScript remains the number one language in GitHub and is the most popular language according to the latest StackOverflow 2020 developer survey. SlashData, in their State of the Developer Nation 19th edition report, shows that the JavaScript community has around 12.4M developers, making it the largest Open Source developer community.
Enter Node.js
Node.js is an open-source JavaScript runtime powered by V8, the same runtime used in Google Chrome, Brave, and Microsoft Edge (Chromium version) web browsers. It’s trusted by companies like NASA, PayPal, Walmart, LinkedIn, Netflix, and of course, Salesforce!
Node.js is perfect for writing highly-concurrent network applications (this means multiple users access the same application at the same time), especially web applications and APIs. Additionally, due to JavaScript’s versatility, you can also write command-line applications (CLIs) and even multi-platform desktop applications. Did you know that Visual Studio Code is written using Node.js? Well, now you know!
Also, Node.js (and JavaScript) has the largest package repository out there: npm. Today, npm hosts more than 1.4M packages and libraries that can be used in any Node.js project.
So far, it sounds great, but why should you as a Salesforce Developer care about Node.js? Well, here are some of the cool things you can build with it and why it matters within the Salesforce Ecosystem.
Developer tooling
As a Salesforce Developer, you might be using the Salesforce CLI (sfdx
); if not, start learning how to use it to create Salesforce Applications. It will help you build applications faster and generally improve your development process. The Salesforce Extension pack for VS Code also uses the sfdx CLI behind the scenes.
The Salesforce CLI and the Heroku CLI are created using oclif, an Open Source framework for creating CLI applications using Node.js. So even if you aren’t writing applications with Node.js, you’re using it every time you create a Salesforce project using sfdx. If you want to extend the CLI using plugins, you can write them using Node.js with either JavaScript or TypeScript as its primary language.
Lightning Web Components
Even though LWC isn’t specifically Node.js, it uses npm as the package repository for distribution, and many different developer tools like Webpack and Rollup to build and compile LWC projects. So if you plan to create and distribute your web components, learning Node.js will help you through the process.
LWC can also be used as a standalone technology. You can create LWC applications using create-lwc-app, a command-line application written using oclif for Node.js. These applications can be deployed to any hosting provider (with or without Node.js support), though the recommended platform for deployment is, of course, Heroku, part of the Salesforce Platform.
Web applications & services
Heroku is a great place to deploy web applications. One of the main supported Open Source runtimes is Node.js; you can deploy not only beautiful looking, pixel-perfect web applications written in any modern web technology (including LWC OSS) but also deploy highly scalable web services.
In the npm ecosystem, you can find multiple libraries and frameworks to write these types of applications. For example, our latest sample application eCars, is written using Node.js. Web frameworks like Express and Fastify are well known, battle-tested, and trusted by many Fortune 500 companies using Node.js for their backend needs. With them, you can write powerful REST APIs, backend-for-frontend layers, GraphQL APIs, and many more.
Salesforce Functions
At Dreamforce 2019 Salesforce Developers announced Salesforce Functions, a powerful serverless runtime to deliver connected experiences with elastic scale, their first planned supported runtime for Salesforce Functions is… you guessed it, Node.js – making it a must-learn technology to create pro-code applications on the Salesforce Platform.
Read the full blog at the link below.