Git Product home page Git Product logo

next.js-typescript-starter-kit's Introduction

Next.js TypeScript Starter Kit CircleCI

samples

see ChangeLog

Feature

  • TypeScript
  • Styled-jsx
  • Module css (PostCSS - cssnext, nested, import)
  • SEO & analytics(Google Analytics, Facebook Pixel, Naver Analytics)
  • Storybook (support module css)
  • Jest & Enzyme (support module css)

Load from CDN

  • font-awesome@5

Installation

git clone https://github.com/deptno/next.js-typescript-starter-kit my-project
cd my-project
rm -r .git
yarn

Run ๐Ÿš€

๐Ÿš€ Test

yarn test # test
yarn test:watch
yarn test:coverage # report coverage
~~:rocket: StoryBook~~

๐Ÿš€ StoryBook

yarn storybook # open browser localhost:6006
yarn build-storybook # Build storybook static assets

๐Ÿš€ Development

yarn start:dev # run

๐Ÿš€ Production

Serve

yarn
yarn build # create .next directory
yarn start # start server

Build static HTML

yarn
yarn build # create .next directory
yarn export # create .out directory

Configuration

Set SEO & analytics variables

src/constants/env.ts

export const GA_TRACKING_ID = ''
export const FB_TRACKING_ID = ''
export const SENTRY_TRACKING_ID = ''

// for meta tag <og & twitter>
export const SITE_NAME = ''
export const SITE_TITLE = ''
export const SITE_DESCRIPTION = ''
export const SITE_IMAGE = ''

If each variable evaluated false, it does not load related library

Usage

import * as classnames from 'classnames'
import * as css from './Home.css'

export const Just = props => <div className={css.className}>
export const Mixed = props => <div className={classnames('row', 'home', css.home)}>

Styled-jsx

const Layout = props =>
  <head>
    <style jsx global>{`
      div > * {
        font-size: 32px;
      }
    `}
    </style>
  </head>
export const Home = props =>
  <div>
    <style jsx>{`{
      color: darkred;
    }`}</style>
    home
  </div>

Others

Related

next.js-typescript-starter-kit's People

Contributors

deptno avatar nishant8bits avatar shanonvl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

next.js-typescript-starter-kit's Issues

How to configure proxy

How in this starter kit to setup proxy for api? Which is running on different instance and port. In original JavaScript we have this solution

But how to setup in this typescript starter kit? Any advice, example, solution?

Add storybook

Expected Behavior

work with typescript

npm run storybook

Current Behavior

  • loader error

Context

branch lab/storybook

reference directory

.storybook
stories

.babelrc may cause side effect

Serving sitemap.xml

Hi @deptno, thanks for creating this great project!
I wondered if you could share how to serve sitemap.xml file. Or maybe even adding this option to the starter kit. Thanks again!

How to add custom router?

Hi, I use typescript in nextjs 5
but use custom router show typescript error is:

Error:(9, 22) TS2306:File '/Users/apple/Documents/project/with-typescript-app/src/routes.ts' is not a module.

can you help me ? thx o_o

What is paho-mqtt for?

I found this in the _document.tsx file but am unsure what it is used for?
<script src="https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.js" type="text/javascript"></script>

_document.tsx: .overrides is not allowed in preset options

Just clone the project
git clone https://github.com/deptno/next.js-typescript-starter-kit.git testnxj

then

cd testnxj
npm install
npm run start:dev

After all getting this issue

Module build failed: Error: [BABEL] .../testnxj/pages/_app.tsx: .overrides is not allowed in preset options
at .../testnxj/node_modules/@babel/core/lib/config/validation/options.js:64:13
at Array.forEach ()
at validate (.../testnxj/node_modules/@babel/core/lib/config/validation/options.js:62:21)
at .../testnxj/node_modules/@babel/core/lib/config/full.js:242:36
at cachedFunction (.../testnxj/node_modules/@babel/core/lib/config/caching.js:40:17)
at loadPresetDescriptor (.../testnxj/node_modules/@babel/core/lib/config/full.js:234:45)
at .../testnxj/node_modules/@babel/core/lib/config/full.js:58:19
at Array.map ()
at recurseDescriptors (.../testnxj/node_modules/@babel/core/lib/config/full.js:56:36)
at recurseDescriptors (.../testnxj/node_modules/@babel/core/lib/config/full.js:87:27)
at loadFullConfig (.../testnxj/node_modules/@babel/core/lib/config/full.js:103:6)
at .../testnxj/node_modules/@babel/core/lib/transform.js:26:33
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickCallback (internal/process/next_tick.js:181:9)

Styles outside of components error

I cannot use

import * as css from 'styled-jsx/css'
const button = css`button { color: hotpink; }`

error:

[ts] Cannot invoke an expression whose type lacks a call signature. Type 'typeof 'styled-jsx/css'' has no compatible call signatures.

storybook not working

There are multiple issues in running it. Can you once try to run it?

  1. ts-loader is not present in package.json.
  2. once i install it.
WARNING in ./stories/index.stories.tsx
Module build failed: Error: You may be using an old version of webpack; please check you're using at least version 4
    at successfulTypeScriptInstance (/Users/ritz078/projects/next.js-typescript-starter-kit/node_modules/ts-loader/dist/instances.js:168:15)
    at Object.getTypeScriptInstance (/Users/ritz078/projects/next.js-typescript-starter-kit/node_modules/ts-loader/dist/instances.js:51:12)
    at Object.loader (/Users/ritz078/projects/next.js-typescript-starter-kit/node_modules/ts-loader/dist/index.js:16:41)
 @ ./stories .stories.tsx$
 @ ./.storybook/config.js
 @ multi ./node_modules/@storybook/react/dist/server/config/polyfills.js ./node_modules/@storybook/react/dist/server/config/globals.js (webpack)-hot-middleware/client.js?reload=true ./.storybook/config.js

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.