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

cra-template-typescript-redux-sauce

v1.0.1

Published

This is a [Create React App](https://github.com/facebook/create-react-app) (CRA) typescript _template_, which allows a quick project start by already having a basic design styled by **Material-UI** and a fully functional and responsive **navigation** incl

Downloads

12

Readme

A quick start Typescript + Redux + Material-UI template

This is a Create React App (CRA) typescript template, which allows a quick project start by already having a basic design styled by Material-UI and a fully functional and responsive navigation including authentication flow, state management via Redux and Redux-Persist and asynchronous side effects with Redux-Sagas already configured.

Usage

npx create-react-app your-project-name --template typescript-redux-sauce

Or

yarn create react-app your-project-name --template typescript-redux-sauce

npx command installs the most recent stable version of CRA from npm.

--template parameter points to this template, note that cra-template- prefix is omitted.

Motivation

Having created several projects from scratch, I've noticed that before a new project can really get started, it always requires the same repetitive work:

  • First I have to create a basic folder structure
  • Then I add a basic navigation
  • For the actual state management I use Redux, where the writing of the boilerplate takes a lot of time
  • Furthermore the state should be persistent, so Redux-Persist has to be configured
  • Finally, for better clarity, I want to separate side effects (like loading data from the server) from the actual logic using Redux-Sagas

Since I don't want to spend hours configuring projects, but rather get straight to development, I have created this template that can be used by anyone who wants to use a similar structure.

What is included

This template offers a basic design, with a responsive navigation and a fully functional authentication flow.

Authentication flow

Enjoy an already pre-styled and functional login and registration form, where all side effects (such as requests to the server) have already been programmed in the form of appropriate sagas, where only the actual request needs to be added

login flow

Authentication is made possible through two different types of routes, namely LayoutRoute and AuthenticatedRoute. While pages using a LayoutRoute can be accessed by anyone, users are automatically redirected to the login page when accessing a AuthenticatedRoute. After login, the user is then redirected back to the desired route.

The following is an exemplary use of the two route types:

<LayoutRoute
    exact
    path="/signup"
    layout={EmptyLayout}
    component={(props : any) => (
        <AuthPage {...props} authState={"SIGNUP"} />
    )}
/>
<AuthenticatedRoute
    exact
    path="/profile"
    title="Profile"
    layout={MainLayout}
    component={ProfilePage}
/>

Responsive navigation

By default, desktop navigation is handled by a sidebar, while a tabBar is used on the phone. The type of navigation can be easily customized in the MainLayout.

Navigation comparison on desktop vs mobile

For the sidebar as well as for the tabBar the available navigation items can be specified via a list, where path, name, icon and whether subroutes also apply are defined.

const navItems : {to: string, name: string, exact: boolean, Icon: any}[] = [
    { to: '/', name: 'Start', exact: true, Icon: HomeIcon},
    { to: '/profile', name: 'Profile', exact: true, Icon: AccountIcon},
];

Available Scripts

In the project directory, you can run:

  • yarn start - runs the app in the development mode. Open http://localhost:3000 to view it in the browser.

  • yarn test - launches the test runner in the interactive watch mode.

  • yarn build - builds the app for production to the build folder.

  • yarn eject - exposes content of react-script package

Redux configuration

This template provides a basic Redux configuration, with Redux-Persist to persist and rehydrate the redux store, Redux-Saga for more structured side effects as well as reduxsauce to make the code a bit more readable.

Folder structure

The basic folder structure looks like this:

your-project-name
├── public
|   └── index.html
├── src
|   ├── __test__
|   ├── assets
|   ├── components
|   ├── pages
|   ├── redux
|   ├── sagas
|   ├── styles
|   ├── utils
|   ├── App.js
|   └── index.js
├── .env
└── package.json

All React Nodes that can be navigated to via routing are stored in the pages folder. Such a page can consist of any number of components, which are stored in the respective folder. As the name suggests, all Sagas are stored in the sagas folder and all the code for redux is stored in the redux folder. Additional useful functions such as custom hooks can be stored in the utils folder.

Styles/CSS/Styling

For the styling of this skeleton app I used Material UI, which is based on Material Design. This includes components like a header, sidebar, tabBar navigation on mobile as well as a sample login and registration form.