An example app with...
- Posts
- Comments
- Authentication
With some nice qualities...
- Full stack JavaScript
- Server side rendering
And you can deploy it to...
Feel free to use without attribution!
- Maurice Kenji Clarke used the setup to create: https://indvstry.io/
- Parker Ruhstaller used the setup to create: https://leafist.com/
- Jay Graber used the setup to create: https://happening.net
- Rich C Smith is working on something wicked cool.
- Maybe you?
- https://next-postgres.herokuapp.com/
https://next-postgres.appspot.com/(disabled because of flexible instance cost)
- NextJS + Custom Express
- Emotion CSS-in-JS
- Postgres
- Sequelize: PostgresSQL ORM
- Passport for local authentication
- Redux
- Babel
- Bad UX/UI so you are forced to make it your own!
- Some "production ready" are concepts baked in for you.
- You'll get server side rendering for free.
- You can move a little faster at a competition or hackathon.
I use Homebrew to manage dependencies.
- Install Postgres:
brew install postgres
. - Install Node 10.7.0+:
brew install node
. (Or update your node)
- On OSX, to run Postgres in a tab on the default port.
postgres -D /usr/local/var/postgres -p 5432
- Postgres config is stored in
./config.js
. - Local database:
sampledb
. - Username:
test
. - Password:
test
. - Please come up with something better in production.
# Enter Postgres console
psql postgres
# Create a new user for yourself
CREATE ROLE yourname WITH LOGIN PASSWORD 'yourname';
# Allow yourself to create databases
ALTER ROLE yourname CREATEDB;
# Exit Postgres console
\q
# Log in as your new user.
psql postgres -U yourname
# Create a database named: sampledb.
# If you change this, update config.js
CREATE DATABASE sampledb;
# Give your self privileges
GRANT ALL PRIVILEGES ON DATABASE sampledb TO yourname;
# List all of your databases
\list
# Connect to your newly created DB as a test
\connect sampledb
# Exit Postgres console
\q
Newbie tip: I use an app called TablePlus for postgres.
In the root directory run these commands:
npm install
npm install -g babel-cli
npm install -g sequelize-cli
sequelize db:migrate
npm run dev
- Visit
localhost:8000
in a browser to start development locally. - You will need postgres running.
To deploy with Heroku, please follow the instructions here.
Please set up Google App Engine and
download the Google Cloud SDK
so you can use gcloud
from the command line.
You will need to add an app.yaml
. It will look something like this:
runtime: nodejs
env: flex
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
env_variables:
NODE_ENV: production
PRODUCTION_USERNAME: your-database-username
PRODUCTION_PASSWORD: your-database-user-password
PRODUCTION_DATABASE: your-database-name
PRODUCTION_HOST: your-database-host
PRODUCTION_PORT: your-database-port
PRODUCTION_SECRET: your-secret
Be sure to read the documentation
Make sure you add app.yaml
to the .gitignore
. You don't want to commit this
file into your Github repository.
Then run npm run deploy
. This configuration will cost you ~$40 a month.
- It is a great service.
- Now 2.0 is about serverless everything
- This example doesn't work with Now 2.0
Feel free to slang any feels to @wwwjim.