Skip to content

Commit e45afe0

Browse files
authored
add Vite-Plugin to Neon add-on (#124)
This PR adds the Vite Plugin from [Neon Launchpad](https://neon.new). It enables the template to automatically create and seed a database without the user having a Neon account. This way everything is immediately functional.
1 parent 658ae59 commit e45afe0

File tree

6 files changed

+23
-5
lines changed

6 files changed

+23
-5
lines changed
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
## Setting up Neon
22

3-
- Set the `DATABASE_URL` in your `.env`.
3+
When running the `dev` command, the `@neondatabase/vite-plugin-postgres` will identify there is not a database setup. It will then create and seed a claimable database.
4+
5+
It is the same process as [Neon Launchpad](https://neon.new).
6+
7+
> [!IMPORTANT]
8+
> Claimable databases expire in 72 hours.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These will be automatically created by Neon Launchpad (https://neon.new).
2+
DATABASE_URL=
3+
DATABASE_URL_POOLER=

frameworks/react-cra/add-ons/neon/assets/_dot_env.local.append

Lines changed: 0 additions & 2 deletions
This file was deleted.

frameworks/react-cra/add-ons/neon/info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Neon",
33
"description": "Add the Neon database to your application.",
4-
"link": "https://neon.tech",
4+
"link": "https://neon.com",
55
"phase": "add-on",
66
"type": "add-on",
77
"modes": ["file-router"],
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"dependencies": {
3-
"@neondatabase/serverless": "^1.0.0"
3+
"@neondatabase/serverless": "^1.0.0",
4+
"@neondatabase/vite-plugin-postgres": "^0.2.0"
45
}
56
}

frameworks/react-cra/add-ons/start/assets/vite.config.ts.ejs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,20 @@ import viteTsConfigPaths from 'vite-tsconfig-paths'<% if (tailwind) { %>
44
import tailwindcss from "@tailwindcss/vite"
55
<% } %><% if (addOnEnabled.sentry) { %>
66
import { wrapVinxiConfigWithSentry } from "@sentry/tanstackstart-react";
7+
<% } %><% if (addOnEnabled.neon) { %>
8+
import postgresPlugin from "@neondatabase/vite-plugin-postgres";
79
<% } %>
810
const config = defineConfig({
911
plugins: [
12+
<% if (addOnEnabled.neon) { %>
13+
postgresPlugin({
14+
seed: {
15+
type: "sql-script",
16+
path: "db/init.sql"
17+
},
18+
referrer: 'create-tanstack'
19+
}),
20+
<% } %>
1021
// this is the plugin that enables path aliases
1122
viteTsConfigPaths({
1223
projects: ['./tsconfig.json'],

0 commit comments

Comments
 (0)