Git Product home page Git Product logo

react-nextjs-samples's Introduction

Nextjs and Vanilla React

This project was created as source material for an informative podcast. The images are pulled randomly from Unsplash.

There are two client projects with the same features. All front-end clients use the backend found in server backend.

Preview

Once you get the client and server running. You should see something like this...

interaction

Installation

In each project folder, you must run npm install. For the clients, their project folders are projects/client/next-client and projects/client/vanilla-client. The server's project folder is projects/server.

Usage

The server can be started using npm start in the server project directory. The server will create a sqlite database.

The client does not provide a way to write to the database; you must do so manually.

Use postman or some other http client to populate the database. The following POST message will work. Change the host to wherever the backend is running.

POST http://localhost:4040/users
Content-Type: application/json

{
    "name": "John"
}

Additionally, you can add tags to users using below.

POST http://localhost:4040/users/<user_id>/tags
Content-Type: application/json

{
    "description": "Developer"
}

Choose which client you want to run, navigate to that project folder, then run npm start. This will launch the development version of that client.

Branches

There are two brances in this project. The master branch compares vanilla react with nextjs including code-splitting. The vanilla-no-lazy is the same example without code splitting in the vanilla react client.

Notes - Client

The client uses redux to manage much of the state.

The root redux state is in src/root-state.types.ts.

For each slice, the slice is in a redux folder.

It is organized

redux\
    [slice-name].types.ts
    [slice-name].actions.ts
    [slice-name].slice.ts

The root state imports [slice-name].types.ts.

The order of imports below

root-state.types.ts < [slice-name].types.ts
[slice-name].slice.ts < [slice-name].actions.ts < [slice-name].types.ts
[slice-name].slice.ts < [slice-name].types.ts

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.