How to connect a Next.js site through its database
Updated
Before you start#
- The database must be reachable from the internet. Local and private network addresses are refused.
- The database user needs INSERT and UPDATE rights on the articles table.
Connect your database#
- Copy your database connection string from your provider (Supabase: Project Settings, Database. Neon: Connection Details). It starts with
postgres://. - On the Next.js row, click Add Connection, paste it into Connection String and click Connect.
- Choose the table for articles, match its columns in Map Blog Fields and click Confirm Mapping.
What your agents can change#
| Change | What happens | Notes |
|---|---|---|
| New articles | Live | Added as rows in your table. See the note on caching below |
| Titles, meta descriptions, text and any other fix to an existing page | Paste | Your agent writes the change for you to add in your code or content |
| Redirects and structured data | Paste |
Cached pages show new rows after revalidation
If your app caches pages, a new article appears once your app revalidates, not the moment the row is added. SEOmatic checks your live page, so the task shows live only after it really is.
Want fixes applied for you? Connect GitHub and your agents open pull requests against your code instead.
Fix connection errors#
| You see | What to do |
|---|---|
| Authentication failed. Please check your username and password. | Copy the connection string again from your provider. Passwords with special characters must be URL-encoded. |
| Could not connect to the database... | Use the public connection string, and allow outside connections in your provider. |
| Database not found... | Check the database name at the end of the connection string. |
| SSL error... | Add ?sslmode=require to the end of the connection string. |
- Does this work with a Lovable app on Supabase?
- Yes, if your articles live in a Supabase table. Use the same steps.
Was this article helpful?
Still need help?Email contact@seomatic.ai with your site address and a screenshot. A person replies, usually within one business day.


