This workshop demonstrates how Vue SSR works using Matt Brophy's vue-ssr-build.
-
Make sure you have Node 8 installed.
-
Run
npm install
to install the app. -
Run
npm run dev
to start the development server. -
Navigate to http://localhost:3000 to see your app.
While the full solution is found in master
, checking out the workshop
branch in this repository will set the repo to a state before all the logic is in place for the simple cat image app. The goal of the workshop is to teach the user to fetch data server side and render a component server side with the fetched data. The app should still be reactive after the application has been hydrated with the store data from the server.
-
Create an action in
store.js
that usesaxios.get
to fetch a cat image from https://aws.random.cat/meow. -
Create a mutation that stores the results of step 1 in the store.
-
Write a getter that fetches all the images that are in the store.
-
In
Cats.vue
usefetchData
to call the action from Step 1 and fetch the data when the component is loaded. -
Write a computed property in
Cats.vue
that calls the getter from Step 4. -
Use the computed property from Step 5 in a
v-for
to render all the images from the store. -
Write a method in
Cats.vue
that is called from a@click
action on a button. This method will dispatch the action from Step 1 to get more cat images. -
Add some styles!