Parameters added to the LIFF URL should be read after liff.init()
Did you know that you can add query parameters to LIFF URLs? In this article, we'll introduce a handy way to use parameters added to a LIFF URL, and a tip for reading them.
You can add additional information to a LIFF URL
You can add additional information such as a path, query parameters, and a URL fragment to a LIFF URL.
https://liff.line.me/{liffId}/?store=shibuyahttps://liff.line.me/{liffId}/summer2026/#coupon
The additional information is carried over to the URL of the page that is ultimately displayed. For example, you can distribute QR codes with a different parameter for each store to switch screens, or distinguish the traffic sources of a campaign.
However, care must be taken regarding the timing of reading additional information, such as parameters.
Read parameters after liff.init() has finished
The additional information added to a LIFF URL is temporarily stored in a query parameter called liff.state, and restored to its original form through a redirect that the liff.init() method performs.
For example, when https://liff.line.me/{liffId}/?store=shibuya is accessed, the following is a typical mistake:
store may be null because the additional information is still stored in liff.state.
So, read the URL after the Promise object returned by the liff.init() method is resolved:
The same applies to paths and URL fragments: once liff.init() has finished, you can read them from location.pathname and location.hash.
Rewriting the URL is even more serious. If you change the URL or perform a server-side redirect before the Promise object is resolved, the LIFF app may not open properly. Libraries that manipulate the URL at load time, such as SPA routers and analytics tags, should also be initialized after liff.init() has finished. For more information, see Process URL changes after liff.init() completes in the LIFF API reference.
Don't modify query parameters starting with liff.
Query parameters starting with liff., such as liff.state, are pieces of information that the LIFF SDK uses for initialization and LIFF-to-LIFF transitions. Changing or deleting them may prevent your LIFF app from working properly, so leave them untouched1.
Wrap-up
For more information about the behavior introduced in this article, see the following documentation:
- Behaviors from accessing the LIFF URL to opening the LIFF app in the LIFF documentation
liff.init()in the LIFF API reference
Footnotes
- For more information, see Initializing the LIFF app in the LIFF documentation. ↩