Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Npm module for extensions #2464

Open
believelody opened this issue Apr 4, 2024 · 2 comments
Open

Npm module for extensions #2464

believelody opened this issue Apr 4, 2024 · 2 comments

Comments

@believelody
Copy link

Hi there,
I installed htmx via npm module. I want to also use some extensions. But mix htmx from npm and extensions in script tag doesn't work. Are there npm module equivalent for extensions ? Or any workaround to use extensions with htmx in .js files ?

Sincerely

@defenestrator
Copy link

defenestrator commented Apr 22, 2024

Can you post the part of your code/config you are referring to?

"But mix htmx from npm and extensions in script tag doesn't work"

The problem is not clearly described. Always include code examples and detailed steps to reproduce when filing Issues

@marisst
Copy link
Contributor

marisst commented Dec 20, 2024

@believelody thank you - this is a very relevant question.

All extensions can be installed using npm. The package naming is htmx-ext-extension-name (replace extension-name with the name of the extension), except for idiomorph. See for example htmx-ext-preload npm package. I have opened a PR which adds npm installation instructions to the extension documentation.

Extensions can currently be imported as ESM modules with this workaround. I have opened another PR to make it possible to integrate them with a clean ESM approach like this:

import `htmx.org`;
import `htmx-ext-extension-name`; // Replace `extension-name` with the extension name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants