Reusable Javascript Method

Share JavaScript Code in Lightning Web Component to Read URL Parameters

In this post, we would create a Lightning Web Component that can be shared across other LWC as a JavaScript library.

We are going to create LWC Component to acts as a utility method to read query parameter , as shown below

As you can see in above code, we just need to create a JavaScript file & meta file for LWC to act as Javascript library. Also, note how function is defined using keyword export. You can have multiple export methods in same LWC that would be used as library in your project.

To use above method in any LWC component, follow below syntax

Posted

in

by


Related Posts

Comments

One response to “Share JavaScript Code in Lightning Web Component to Read URL Parameters”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Jitendra Zaa

Subscribe now to keep reading and get access to the full archive.

Continue Reading