- Setup your Sequin Sync
- Connect to Sequin’s Postgres Proxy
- Set up API route handlers
Setup a Sequin sync
To setup a Sequin sync, Sequin will guide you through authenticating, selecting the data you want to sync, and connecting to your database. Read our getting started guide for step-by-step instructions.Connect to Sequin’s Postgres Proxy
Sequin uses a Postgres Proxy to interface with your Sequin-synced tables. The Proxy lets Sequin capture inserts, updates, and deletes you make in your database and commit them to the API. To use Sequin’s Postgres Proxy in your Next.js app, you can treat it as a regular Postgres database. The following example creates a connection to the Proxy using the pg client:Setup your API route handlers
Next.js Route Handlers allow you to create custom request handlers for a given route using the Web Request and Response APIs. In this setup, a Next.js frontend interacts with a backend server. The backend connects to a PostgreSQL database usingpg
and exposes API routes. The frontend communicates with these routes to execute database queries and receive responses.
The following is an example of a route handler in Next.js:
./api/salesforce/products/select/route.js
and therefore results in the following endpoint:
Reading Data
With your API data in Postgres, your route handler functions can just use SQL to interface with your data. Here’s an example function that queries for all Salesforce products in an organization:api/salesforce/products/select
: