Skip to content

Files

Latest commit

eec204f · Nov 29, 2024

History

History

deploy-with-netlify-functions

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jun 27, 2024
Aug 2, 2024
Nov 29, 2024

Getting started with Neon and Netlify functions

This is the code repository for the guide on how to deploy a Netlify functions application with Neon. Follow the guide to set up your Neon project and configure the Netlify CLI.

Store your Neon credentials

Run the command below to copy the .env.example file, to the neon-netlify-example directory, and rename it to .env.

cp .env.example neon-netlify-example/.env

Store your Neon credentials in this .env file.

DATABASE_URL="postgresql://neondb_owner:...@ep-...us-east-1.aws.neon.tech/neondb?sslmode=require"
  • user is the database user.
  • password is the database user’s password.
  • endpoint_hostname is the host with neon.tech as the TLD.
  • dbname is the name of the database. “neondb” is the default database created with each Neon project.
  • ?sslmode=require an optional query parameter that enforces the SSL mode while connecting to the Postgres instance for better security.

Important: To ensure the security of your data, never expose your Neon credentials to the browser.

Test the application locally

Initialize a Netlify site

Change to the neon-netlify-example directory and run the command below to install project dependencies:

cd neon-netlify-example && npm install

Run the command below to initialize a new Netlify site:

netlify sites:create

Test running the application locally by running the command below:

netlify dev

Deploy the application to Netlify platform

Follow the guide for further instructions on how to deploy the functions to the Netlify platform.