Skip to content

Commit a45bf8c

Browse files
authored
Fix deploy button in with-xata example (vercel#43608)
The deploy button of the `with-xata` example is not working properly because we were lacking the integration to configure the env variables. [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/SferaDev/nextjs-demo/tree/fix-with-xata-deploy/examples/with-xata&project-name=with-xata&repository-name=with-xata&integration-ids=oac_IDpMECDuYqBvAtu3wXXMQe0J) Taking advantage of the PR, some other changes: - Adding `alt` to `next/image` to fix build with latest version - Update readme to add more information in the Xata CLI section - Use a new command to initialize the database schema on first deployment - Remove hardcoded URL in `xata.codegen.ts` - Remove deprecated `formatVersion` in `schema.template.json` - Update dependencies Note: The integration is still work in progress, it works for the `Deploy to Vercel` button but we want to improve the UI/UX before submitting it to the Marketplace, keeping it unlisted for a while.
1 parent 07d52ce commit a45bf8c

File tree

5 files changed

+21
-20
lines changed

5 files changed

+21
-20
lines changed

examples/with-xata/README.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ With this template you get out-of-the-box:
1414

1515
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/with-xata)
1616

17-
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-xata&project-name=with-xata&repository-name=with-xata)
17+
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-xata&project-name=with-xata&repository-name=with-xata&integration-ids=oac_IDpMECDuYqBvAtu3wXXMQe0J)
1818

1919
## Demo
2020

@@ -36,15 +36,21 @@ yarn create next-app --example with-xata with-xata-app
3636
pnpm create next-app --example with-xata with-xata-app
3737
```
3838

39-
### Link Your Xata Workspace and Run Codegen
39+
### Link With Your Xata Workspace And Update Types
4040

41-
> 💡 consider [installing the Xata CLI globally](https://xata.io/docs/cli/getting-started), it will likely improve your experience managing your databases
41+
> 💡 We recommend installing the [Xata CLI](https://xata.io/docs/cli/getting-started) globally, but you can also use `npx @xata.io/cli` instead of `xata` in the commands below.
42+
43+
You can link your project with a Xata workspace by running the following command:
4244

4345
```sh
44-
npm run start:xata
46+
xata init
4547
```
4648

47-
> ⚠️ once linked, you can just run `xata` to re-generate types.
49+
To update your types, run the following command:
50+
51+
```sh
52+
xata codegen
53+
```
4854

4955
### Start Coding
5056

examples/with-xata/package.json

+8-10
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@
44
"dev": "next dev",
55
"build": "next build",
66
"start": "next start",
7-
"start:xata": "xata init --schema=schema.template.json --codegen=utils/xata.codegen.ts",
8-
"poststart:xata": "xata codegen",
9-
"xata": "xata codegen"
7+
"xata": "xata codegen",
8+
"postinstall": "npx @xata.io/cli@latest schema upload schema.template.json --branch main --create-only --yes"
109
},
1110
"devDependencies": {
12-
"@types/node": "18.6.5",
13-
"@types/react": "18.0.17",
14-
"@types/react-dom": "18.0.6",
15-
"@xata.io/cli": "0.8.1",
16-
"eslint": "8.21.0",
11+
"@types/node": "18.11.10",
12+
"@types/react": "18.0.25",
13+
"@types/react-dom": "18.0.9",
14+
"eslint": "8.28.0",
1715
"eslint-config-next": "latest",
18-
"typescript": "4.7.4"
16+
"typescript": "4.9.3"
1917
},
2018
"dependencies": {
21-
"@xata.io/client": "^0.16.1",
19+
"@xata.io/client": "^0.21.3",
2220
"next": "latest",
2321
"react": "^18.2.0",
2422
"react-dom": "^18.2.0"

examples/with-xata/pages/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function IndexPage({
3131
return (
3232
<main>
3333
<header>
34-
<Image src={xatafly} priority />
34+
<Image src={xatafly} alt={'Xata'} priority />
3535
<h1>
3636
Next.js with<span aria-hidden>&#8209;</span>xata
3737
</h1>

examples/with-xata/schema.template.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"formatVersion": "",
32
"tables": [
43
{
54
"name": "nextjs_with_xata_example",

examples/with-xata/utils/xata.codegen.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ export type NextjsWithXataExampleRecord = NextjsWithXataExample & XataRecord
2424

2525
const DatabaseClient = buildClient()
2626

27-
const defaultOptions = {
28-
databaseURL: 'https://xata-uq2d57.xata.sh/db/examples',
29-
}
27+
const defaultOptions = {}
3028

3129
export class XataClient extends DatabaseClient<SchemaTables> {
3230
constructor(options?: BaseClientOptions) {

0 commit comments

Comments
 (0)