App.js handle for wp_add_inline_script

Hi everybody,
I’d like to know which is the better way to add inline scripts in sage 10.

Sage 10 enqueues scripts in this way by deafault:


Now I need to add an inline script when app.js is enqueued.
To doing this, I tried with this line of code:

wp_add_inline_script('sage/app.js', $js);

but it doesn’t work cause the handle is not right.

I’ve taken a look at the bundle('app')->enqueue() method and I figured out that handles in the bundle of my theme are: “app/0”, “app/1”, “app/2”, “app/3”.
The last one seems to be the handle I need and, testing it, script is added correctly.

Is there a way to get the app.js handle? An helper or something similar?

Thank you for your help.


Haha. Deleted my post. @Log1x has the real solution.


You can use ->inline() on your bundle call. Not sure if you missed that since it’s in a trait.


@Log1x Thank you so much! I completely missed it :man_facepalming: