Skip to content

DefangSamples/sample-nextjs-postgres-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Next.js & Postgres

1-click-deploy

This is a sample Next.js application that uses Postgres as a database. It is a simple example that demonstrates how to connect to a Postgres database from a Next.js application: on each request it takes the user's IP address, geo-locates it, and stores the result in the database, then displays the last 20 results on the home page.

Prerequisites

  1. Download Defang CLI
  2. (Optional) If you are using Defang BYOC authenticated with your AWS account
  3. (Optional for local development) Docker CLI

Development

To run the application locally, you can use the following command:

docker compose -f compose.dev.yaml up --build

Configuration

For this sample, you will need to provide the following configuration. Note that if you are using the 1-click deploy option, you can set these values as secrets in your GitHub repository and the action will automatically deploy them for you.

POSTGRES_PASSWORD

A password that will be used to connect to the Postgres database.

Deploying

  1. Open the terminal and type defang login
  2. Use the defang config command to setup environment variables.
  3. Type defang compose up in the CLI.
  4. Your app will be running within a few minutes.

Title: Next.js & Postgres

Short Description: A sample Next.js application that uses Postgres as a database.

Tags: Next.js, Postgres, Database, Node.js

Languages: TypeScript, JavaScript

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5