npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@maicol07/inertia-mithril

v1.0.3

Published

The Mithril.js adapter for Inertia.js

Downloads

62

Readme

Inertia.js Mithril Adapter

This is the Mithril.js client-side adapter for Inertia. Inertia.js lets you quickly build modern single-page apps using classic server-side routing and controllers, without building an API.To use Inertia.js you need both a server-side adapter as well as a client-side adapter.

Server-side setup

Be sure to follow the installation instructions for the server-side framework you use.

Client-side setup

Install dependencies

Install the Mithril adapter using your preferred package manager (NPM is provided below for reference).

npm install @maicol07/inertia-mithril

Initialize app

Next, update your main JavaScript file to boot your Inertia app. To accomplish this, we'll initialize Mithril with the base Inertia component.

import m from 'mithril'
import { createInertiaApp } from '@maicol07/inertia-mithril'

createInertiaApp({
  resolve: name => {
    const pages = import.meta.glob('./Pages/**/*.jsx', { eager: true })
    return pages[`./Pages/${name}.jsx`]
  },
  setup({ el, App, props }) {
    if (!el) {
      throw new Error("No mounting HTMLElement found");
    }

    m.mount(el, {
        view: () => m(App, props) // or with JSX: m.mount(el, <App {...props}/>)
    });
  },
})

The setup callback receives everything necessary to initialize Mithril, including the root Inertia App component.

The resolve callback tells Inertia how to load a page component. It receives a page name (string), and returns a page component module. How you implement this callback depends on which bundler (Vite or Webpack) you're using.

Visit the Inertia Client-side setup page to learn more.

Shared data

To share data between server and Mithril, it's pretty simple:

  1. Follow the Shared data instructions for the server
  2. You can access data via the vnode.attrs.page.props in your page component.

Title & meta

To be developed

Links

To create links to other pages within an Inertia app, you will typically use the Inertia <Link> component. This component is a light wrapper around a standard anchor <a> link that intercepts click events and prevents full page reloads from occurring. This is how Inertia provides a single-page app experience once your application has been loaded.

Creating links

To create an Inertia link, use the Inertia Link component. Note, any attributes you provide will be proxied to the underlying HTML tag.

import {Link} from '@maicol07/inertia-mithril'

m(Link, {href: '/'}, 'Home')
// or use JSX:
// <Link href="/"></Link>

Almost all the other features are explained in Inertia docs (the React adapter syntax is very similar to Mithril one).

Demo (outdated)

Here is a working demo using this adapter.

https://pingcrm-mithril.tebe.ch

More about Inertia

Visit inertiajs.com to learn more.