Giter Site home page Giter Site logo

nextjs-react-router's Introduction

NextJS React-Router

This is an experiment to find out how to migrate an existing react app (with typescript/react-router/server-side-rendering/jest/eslint etc.) to Next.JS.

Usage

  1. Clone the repo
  2. Run npm run dev, which spins up the server code (server/start.ts)
  3. Run npm run build to build the production code, which can be started with npm start

Structure

  • The main nextjs app is in pages/, with the output javascript in .next/

    • pages/_app.tsx is the startpoint of the application, and sets up react-router for both client and server-side.

      Since we're not using the default nextjs router, we're forced to opt out of the static site generation and specify a getInitialProps method here so nextjs populates the actual request path correctly.

    • pages/index.tsx contains a Home component that sets up the react-router routes

    • pages/_document.tsx handles the redirects triggered by react-router

  • The server-side bootstrap code is in server/, with the output javascript in dist/

    • server/start.ts sets up the nextjs application

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.