Black Friday Super Sale! Limited Time 50% OFF for All-Access Plans
Save 50% Now

How to structure my JS-based SPA with Metronic theme layout (header, sidebar, content)


I’m building a JavaScript-based site deexn com and want to integrate the Metronic/KeenThemes layout properly with my project structure. I’m unsure how to organize the theme’s HTML/JS files within my JS architecture and how to reinitialize Metronic components (like dropdowns, menus, tooltips, etc.) when loading dynamic content or switching views. Can you guide me on the recommended structure and best practices for using Metronic in a JS project, including how to keep the layout persistent while updating page content dynamically?


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (2)


If you're building a JS-based SPA, the key with Metronic is to keep the main layout persistent (header, sidebar, footer) and only replace the content area.
In our projects at Deexn, we structure it like this:

/assets/metronic/ → original theme JS/CSS

/src/layout/ → wrapper layout (header, aside, toolbar)

/src/views/ → SPA pages

/src/app.js → router + Metronic component reinitialization

Whenever you load a new view, run:

KTApp.initComponents();
KTMenu.updateDropdowns();

This ensures menus, drawers, tooltips, etc. re-activate after dynamic content changes.
Keeping the layout static and reinitializing components on view switch gives you a clean SPA structure that works smoothly with Metronic.



Hi,

For building an SPA, we recommend using the React version of Metronic 9 Tailwind. It’s specifically designed to support dynamic content routing and works seamlessly as a single-page application:
https://keenthemes.com/metronic#concepts

The default HTML/JS version of Metronic would require significant customization to function as an SPA, and such implementation is beyond the scope of what we can support through this channel.

Regards,
Sean


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(