function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Taylor YoungTaylor Young 

How can I export source code for a lightning web component from Salesforce?

I worked on an SFDX project a while ago and deployed it to Salesforce. It is up and running in our org's Sandbox. I can't find the source code locally or on GitHub. Is it possible to export the source code from Salesforce?

Thank you,
Taylor
Best Answer chosen by Taylor Young
ShirishaShirisha (Salesforce Developers) 
Hi Taylor,

Greetings!

Currently there is no possibility to view the code in LWC directly in Salesforce.However,you can use the Visual Studio code to view your LWC code.

Other easy approach to extract the metadata from workbench with using below package.xml
 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>*</members> <name>AuraDefinitionBundle</name> </types> <types> <members>*</members> <name>LightningComponentBundle</name> </types> <version>46.0</version> </Package>


Trailmix to learn LWC basic to advance - https://trailhead.salesforce.com/en/users/sakthivel/trailmixes/lightning-web-component-lwc

Here:
LightningComponentBundle - to get all your LWC Bundle like html, js, css, etc
AuraDefinitionBundle- to get all your Aura component Bundle like component, controller, helper class, css, etc

Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.

Warm Regards,
Shirisha Pathuri