Skip to content

Instantly share code, notes, and snippets.

@erictherobot
Created October 16, 2017 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erictherobot/98bb298c35702b57147f86d7ab3a0697 to your computer and use it in GitHub Desktop.
Save erictherobot/98bb298c35702b57147f86d7ab3a0697 to your computer and use it in GitHub Desktop.
nextjs-installer.sh <yourappname>
#!/bin/bash
# ./nextjs-installer <project-name>
# Create a new Next.js Project
echo "Creating Next.js Project: $1 ..."
mkdir $1
cd $1
mkdir pages
mkdir components
mkdir static
echo "Created directories pages, components, static"
cat <<'EOF' > package.json
{
"name": "",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"dev": "next | json-server --watch db.json --port 3004"
},
"dependencies": {
"next": "*",
"react-bootstrap": "*"
}
}
EOF
cat <<'EOF' > db.json
{
"posts": [
{ "id": 1, "title": "json-server", "author": "typicode" }
],
"comments": [
{ "id": 1, "body": "some comment", "postId": 1 }
],
"profile": { "name": "typicode" }
}
EOF
yarn
yarn add next
echo "import React from 'react'
import { Button } from 'react-bootstrap'
export default () => (
<div>Welcome to next.js! <Button>Hello Bootstrap</Button></div>
)" > pages/index.js
yarn dev
echo "Completed install!"
atom .
open http://localhost:3000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment