2

From the documentation on Salesforce site: https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.get_started_local_dev_setup

It is mentioned that in order to use local environment for lightning web components, we need to have a dev hub. Also, some more documentations mention that we need to use dev hub or scratch orgs to use sfdx. But I just tried the local dev environment without any dev hub or scratch org just by initiating the server in the VSCode terminal. So just in case if a developer wants to check something quickly for the first time, he needs to enable dev hub, create scratch org and a long way to write a simple Hello World demo. Is there any reason behind this that Salesforce mentions this long way, recommended way could be mentioned although?

2

If all you want is a simple Hello World demo, you can just go over to the Playground and play around. You won't have any server features, such as Apex, saving or loading records, etc, but you can get a feel for LWC instantly with this tool.

However, once you want to start writing code that you want to put in your org, you'll want at least SFDX to deploy to the server. You can choose a different IDE, if you're interested, it's just that VS Code happens to be the supported default.

Other IDEs certainly exist, though most of them have some sort of licensing cost, which is one reason why VS Code was chosen over potentially more capable IDEs.

Even then, for deployments, you don't need a Dev Hub. You can choose to deploy LWC components directly into a Sandbox or Developer Edition org, without the need for a Scratch Org.

We're already using LWC in our projects, and we haven't migrated to using DX format, Unlocked Packages, or Scratch Orgs. You'll want to figure those out eventually, but there's no requirement that a Dev Hub or Scratch Orgs to be involved to get started.

Edit: I just realized that this question is in regards to a "local lwc server." The rest of this answer is still valid, although it should be noted that the local server feature is relatively advanced, and not something you'd probably want to do as a beginner just starting LWC.

| improve this answer | |
  • I just gave an example for local dev server, and I asked the same what you wrote for. Yes, you are right dev hub is not needed atleast for lwc or dev server, but I wanted to know the reason why Salesforce mentioning everywhere to use it even if it is not needed. Not a beginner with LWC or scratch orgs or playground, have worked with them and once tried unlocked packages as well, just wanted to try the local dev server so wrote Hello World there in my question :-) – Aditya Vijay Jan 30 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.