Skip to content

Commit fa15554

Browse files
committed
add readme
1 parent 0411525 commit fa15554

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# From Meteor to Next
2+
3+
This repository demoes using a Vulcan Next frontend with a legacy Vulcan Meteor backend.
4+
This is targeted at existing Vulcan application that needs a progressive migration.
5+
6+
## Start the Meteor server
7+
8+
```sh
9+
cd ./meteor-backend
10+
# Install if not yet done: meteor npm install
11+
git checkout demo/with-next-frontend
12+
meteor npm run start -- --port=3001
13+
```
14+
15+
## Start the Next frontend
16+
17+
```sh
18+
cd ./next-frontend
19+
# Install if not yet done: yarn install
20+
git checkout demo/with-meteor-backend
21+
yarn run dev
22+
```
23+
24+
## How it works
25+
26+
### Frontend
27+
28+
Top priority of this demo is to connect a Vulcan Next frontend to an existing Meteor backend.
29+
30+
- Next.js Apollo client is configured to use Meteor's graphql endpoint, running on port 3001. This value is set in `next-frontend/.env.development`.
31+
- Seed from Next.js is disabled in `next-frontend/src/api/seed.ts` (we suppose you handle this in Meteor directly)
32+
- MONGO_URI is changed to connect to the Meteor DB. Technically, this is not necessary if you use Next only for frontend, but we still need this change this value to deactivate the demo mode that is automatically enabled when we detect you are using the demo database.
33+
- useUser hook will rely on Meteor useCurrentUser under the hood in `next-frontend/src/components/user/hooks.ts`
34+
- Changed `next-frontend/src/pages/login.tsx`, `next-frontend/src/pages/signup.tsx` and `next-frontend/src/components/layout/Footer.tsx` to use legacy hooks to connect to Meteor. NOTE: in a future iteration, we should abstract the Next.js version into hooks, to make this cleaner
35+
- Define Apollo CORS so we can include crendentials in `meteor-backed/settings.json`
36+
- TODO: cross-origin set-cookie are not working. We might need to update Vulcan to support this https://stackoverflow.com/questions/46288437/set-cookies-for-cross-origin-requests, https://stackoverflow.com/questions/1134290/cookies-on-localhost-with-explicit-domain/1188145#1188145
37+
In Vulcan, relevant file is: packages/vulcan-users/lib/server/mutations.js, it might need some additional headers/setup to work ok in production
38+
39+
40+
### Full-stack = progressively use Next as your backend
41+
42+
In the long run, the goal is to transition the Meteor backend to Next as well, using Next API routes.
43+
44+
- Next is configured to use the same Mongo database as Meteor locally. To get the URL of the local Meteor database, run `meteor mongo -U`. It's most probably something like this: `mongodb://127.0.0.1:3002/meteor`
45+
- TODO: in Next, configure Passport to authenticate users using the existing Mongo database from Meteor

meteor-backend

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 1856f7a2e9995c42c711f1600a2ea57ab561a26e
1+
Subproject commit bd67f687a14f78558d3faa5f00e114bf33080d88

next-frontend

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit ac61f0aea25c7df2d006cbf31ffb343941b1616a
1+
Subproject commit e1e567460dd4175b6be9953ad297b82751b3cbed

0 commit comments

Comments
 (0)