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

catalyst-core-internal

v0.0.1-beta.37

Published

Web framework that provides great performance out of the box

Downloads

674

Readme

Catalyst

Frontend framework with server rendering support for web applications.

Table of Contents

  • Overview
  • Installation
  • Data Fetching with Catalyst
    • serverFetcher
    • clientFetcher
    • refetch (for data revalidation)
  • State Management

Overview

This package provides a way to proxy your request through your server. It allows you to cache your incoming request to improve your server response time.

Installation

System Requirements

  • Node version 20.4.0 or later
  • macOS and Linux are supported

Automatic Installation

  • Run the following commands in the directory where you want to set up the Catalyst app.
npx create-catalyst-app@latest

If successful, you will see the following prompts in your terminal.

  • Enter the name of your Catalyst application.
  • Choose state management.
  • Once packages are installed,start the development server by running the following command.
cd project-name && npm run start
  • Navigate to http://localhost:3005

The dev server should be running now.

Visit our official documentation: https://catalyst.1mg.com/public_docs/content/installation

Data Fetching with Catalyst

we have serverFetcher function for fetching with SSR and clientFetcher function for fetching during client side rendering and navigations.

serverFetcher

server fetcher will get request, request params, search params and store (if project is setup with redux or rtk) as arguments. We can declare it as an async function and use await for fetching or use then chaining for data fetching.

if server fetcher is called for a route then client fetcher will not be called for that route, unless called with refetch.

Home.serverFetcher = async ({ req, params, searchParams }, { store }) => {
    store.dispatch(someAction())
    const res = await fetch("some_url")
    const json = await res.json()
    return json
}

data returned from fetcher function will be accessible through useCurrentRouteData() hook provided by router.

const [data, error, isFetched] = useCurrentRouteData()

error and loading state would be handled by router.

clientFetcher

client fetcher would be called on client side rendering and client side navigations. store would be available as a param in client side for dispatching redux/rtk actions.

Home.clientFetcher = async ({ route, location, params, searchParams, navigate }, { store }) => {
    store.dispatch(someAction())
    const res = await fetch("some_url")
    const json = await res.json()
    return json
}

data returned from client fetcher function will be accessible through useCurrentRouteData() hook provided by router (hook for data access through client is same).

const [data, error, isFetched] = useCurrentRouteData()

refetch (for data revalidation)

refetch function can be used were we need to execute clientFetcher based on some condition(such as for infinite scroll or some state change inside container or onClick.)

We can pass arguments in refetch function which would

const [data,error,isFetched,refetch] = useCurrentRouteData()

useEffect(()=>{
  refetch({refetchArgument:some_value})
},[arg])

clientFetcher = ({},{refetchArgument}) => {

  const res = await api_call // refetchArg can be used as a param in api call
  return res
}

State Management

state management wrappers are defined in stateProvider.js file

store can be configured by manipulating store/index.js as per user requirements (custom middlewares etc can be added in this way.

initial state and request object would be provided in createStore function which will be called on server and client, we use the params to add additional arguments and middlewares in redux store.

const configureStore = (initialState, cookies, requestObj, customHeaders) => {
    const api = fetchInstance
    const store = createStore({
        reducer: rootReducer,
        middleware: (getDefaultMiddleware) =>
            getDefaultMiddleware({
                thunk: {
                    extraArgument: { api },
                },
            }),
        preloadedState: initialState,
    })
    return store
}

export default configureStore

Documentation

Visit https://catalyst.1mg.com to view the full documentation.