Skip to content

Commit

Permalink
Update and improve Postgres SvelteKit example (#846)
Browse files Browse the repository at this point in the history
### Description

- update to latest version of Svelte(Kit)
- use static environment variable feature for better local development
experience
- format code
- improve readme

Related to vercel/feedback#50067

### Demo URL

[<!--
Provide a URL to a live deployment where we can test your PR. If a demo
isn't possible feel free to omit this section.
-->](https://postgres-sveltekit-nu-eight.vercel.app/)

### Type of Change

- [ ] New Example
- [x] Example updates (Bug fixes, new features, etc.)
- [ ] Other (changes to the codebase, but not to examples)

### New Example Checklist

- [ ] 🛫 `npm run new-example` was used to create the example
- [ ] 📚 The template wasn't used but I carefuly read the [Adding a new
example](https://github.com/vercel/examples#adding-a-new-example) steps
and implemented them in the example
- [ ] 📱 Is it responsive? Are mobile and tablets considered?
  • Loading branch information
dummdidumm authored Jan 3, 2024
1 parent 90b4fac commit f1d2b20
Show file tree
Hide file tree
Showing 7 changed files with 759 additions and 519 deletions.
6 changes: 6 additions & 0 deletions storage/postgres-sveltekit/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
POSTGRES_URL=
POSTGRES_URL_NON_POOLING=
POSTGRES_USER=
POSTGRES_HOST=
POSTGRES_PASSWORD=
POSTGRES_DATABASE=
34 changes: 10 additions & 24 deletions storage/postgres-sveltekit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,44 +28,30 @@ You can choose from one of the following two methods to use this repository:

### One-Click Deploy

Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=vercel-examples):
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=vercel-examples)

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fexamples%2Ftree%2Fmain%2Fstorage%2Fpostgres-sveltekit&project-name=postgres-sveltekit&repository-name=postgres-sveltekit&demo-title=Vercel%20Postgres%20Next.js%Sveltekit&demo-description=Simple%20Next.js%20template%20that%20uses%20Vercel%20Postgres%20as%20the%20database.&demo-url=https%3A%2F%2Fpostgres-sveltekit.vercel.app%2F&demo-image=https%3A%2F%2Fpostgres-starter.vercel.app%2Fopengraph-image.png&stores=%5B%7B"type"%3A"postgres"%7D%5D)
create-svelte

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
### Clone and Deploy

## Creating a SvelteKit project

If you're seeing this, you've probably already done this step. Congrats!
Execute the following command to download the example into the `my-project` folder:

```bash
# create a new project in the current directory
pnpm create svelte@latest

# create a new project in my-app
pnpm create svelte@latest my-app
npx degit@latest https://github.com/vercel/examples/storage/postgres-sveltekit my-project
```

## Developing
Once you've created the project and installed dependencies with `pnpm install`, copy the `.env.example` file in this directory to `.env.local` (which will be ignored by Git). Then open `.env.local` and set the environment variables to match the ones in your Vercel Storage Dashboard.

Once you've created a project and installed dependencies with `pnpm install`, start a development server:
Alternatively, if you have setup a project already and you have installed the Vercel CLI, you can also pull the environment variables using the following command:

```bash
pnpm dev

# or start the server and open the app in a new browser tab
pnpm dev --open
vercel env pull .env.local
```

## Building

To create a production version of your app:
Next, run SvelteKit in development mode:

```bash
pnpm build
pnpm dev
```

You can preview the production build with `pnpm preview`.

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=vercel-examples) ([Documentation](https://vercel.com/docs/frameworks/sveltekit)).
18 changes: 9 additions & 9 deletions storage/postgres-sveltekit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/adapter-vercel": "^2.4.2",
"@sveltejs/kit": "^1.5.0",
"@sveltejs/adapter-vercel": "^4.0.3",
"@sveltejs/kit": "^2.0.6",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"autoprefixer": "^10.4.14",
"postcss": "^8.4.23",
"svelte": "^3.54.0",
"svelte-check": "^3.0.1",
"tailwindcss": "^3.3.1",
"svelte": "^4.2.8",
"svelte-check": "^3.6.2",
"tailwindcss": "^3.3.2",
"turbo": "^1.9.3",
"typescript": "^5.0.0",
"vite": "^4.2.0"
"typescript": "^5.0.4",
"vite": "^5.0.10"
},
"type": "module",
"dependencies": {
"@vercel/postgres": "^0.1.3",
"@vercel/postgres": "^0.5.1",
"dotenv": "^16.0.3",
"ms": "^2.1.3",
"ws": "^8.13.0"
Expand Down
Loading

24 comments on commit f1d2b20

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

domains-api – ./solutions/domains-api

domains-api-git-main.vercel.rocks
domains-api.vercel.rocks

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

alt-tag-generator – ./solutions/alt-tag-generator

alt-text-generator.vercel.app
alt-tag-generator-vercel-solutions-vtest314.vercel.app
alt-tag-generator-git-main-vercel-solutions-vtest314.vercel.app

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

cron – ./solutions/cron

cron-git-main.vercel.rocks
cron-template.vercel.app
cron.vercel.rocks

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

edge-functions-i18n – ./edge-middleware/i18n

edge-functions-i18n.vercel.app
edge-functions-i18n.vercel.sh
edge-functions-i18n-git-main.vercel.sh

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

postgres-kysely – ./storage/postgres-kysely

postgres-kysely.vercel.app
postgres-kysely-git-main.vercel.rocks
postgres-kysely.vercel.rocks

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

postgres-starter – ./storage/postgres-starter

postgres-starter.vercel.app
postgres-starter-git-main.vercel.rocks
postgres-starter.vercel.rocks

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

redirect-with-fallback – ./app-directory/redirect-with-fallback

redirect-with-fallback-vercel-solutions-vtest314.vercel.app
redirect-with-fallback-git-main-vercel-solutions-vtest314.vercel.app
redirect-with-fallback.vercel.app

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

postgres-prisma – ./storage/postgres-prisma

postgres-prisma.vercel.app
postgres-prisma.vercel.rocks
postgres-prisma-git-main.vercel.rocks

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

geolocation-script – ./edge-middleware/geolocation-script

geolocation-script-git-main-vercel-solutions-vtest314.vercel.app
geolocation-script.vercel.app
geolocation-script-vercel-solutions-vtest314.vercel.app

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

postgres-pgvector – ./storage/postgres-pgvector

postgres-pgvector-git-main.vercel.rocks
postgres-pgvector.vercel.app
postgres-pgvector.vercel.rocks

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

kv-redis-starter – ./storage/kv-redis-starter

kv-starter.vercel.app
nextjs-kv-starter.vercel.app
kv-redis-starter.vercel.app
kv-redis-starter-git-main.vercel.rocks
kv-redis-starter.vercel.rocks

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

blob-starter – ./storage/blob-starter

blob-starter.vercel.app
blob-starter-git-main.vercel.rocks
blob-starter.vercel.rocks

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

postgres-drizzle – ./storage/postgres-drizzle

postgres-drizzle.vercel.app
postgres-drizzle.vercel.rocks
postgres-drizzle-git-main.vercel.rocks

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

edge-geolocation-country-block – ./edge-middleware/geolocation-country-block

edge-geolocation-country-block-git-main-now-examples.vercel.app
edge-geolocation-country-block-now-examples.vercel.app
edge-geolocation-country-block.vercel.app

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

examples – ./storage/postgres-starter

examples.vercel.rocks
examples-git-main.vercel.rocks
examples-bice.vercel.app

@vercel
Copy link

@vercel vercel bot commented on f1d2b20 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

next-flask – ./python/nextjs-flask

nextjs-python.vercel.app
next-flask.vercel.rocks
nextjs-flask-starter.vercel.app
next-flask-git-main.vercel.rocks

Please sign in to comment.