-
Notifications
You must be signed in to change notification settings - Fork 6
Draft Quickstart
Note, wiki articles are non authoritative, draft content. See the wiki Home page for more details.
This Quickstart doesn't work yet. It is an example of the type of experience we could aim to deliver for new developers. When we are closer to having the CLI ready, this can go into a PR.
Welcome to Cardstack! Follow these step-by-step instructions to make your own full-stack project using the Card SDK.
To get started, you will need the following installed on your computer:
- npm or yarn
- Node.js version 8 or higher
- Docker - a free container manager
- Linux and Mac systems should also install Watchman
Then, install the Cardstack CLI:
npm install -g @cardstack/cliIf you're new to developing in JavaScript, watch this video to see someone setting up their Cardstack developer environment.
The Hub is the environment where your Card will run.
cardstack runNow you can visit http://localhost:4200 and see the welcome message:
IMAGE
The welcome message you saw is displayed on a Card. Open the file at path/to/file and change the markup:
some markupYour page at http://localhost:4200 will reload. In your Card template, you can write regular HTML or Ember Handlebars.
Next, we'll add some data persistence. In this tutorial, we'll create a form input whose results will be saved into the postgres database.
Run the following command to generate a Card Schema that uses the postgres plugin:
cardstack generate schema --postgresYou'll see a new Card Schema file, filename.js, which has some boilerplate in it to get you started:
// show boilerplate configured to postgresAdd a formEntry, where we will store user inputs:
// show adding schemaNow, let's set up an input in the card and a submit button. First, we will create our form.
<label for="my-input">
What is one of your favorite locations for photography?
</label>
<input type="text" id="my-input" value={{this.userEntry}}>
<button>
Submit
</button>Next, we tell the button what to do when clicked. In your path/to/card.js file, let's write a function that we can attach to the button.
@action
submitLocation() {
// save this.userEntry to postgres
}Now, let's add this form action to the button we made in path/to/card.hbs:
<button onclick={{action 'submitLocation'}}>
Submit
</button>Visit http://localhost:4200 in your browser. When you click the button, an API request will save the entry to the database!
Once you have made some entries, it's time to display them in the app. Add the following to your path/to/card.hbs, below the button:
<h1>Previous entries</h1>
<ul>
{{#each content.formEntries as |entry|}}
<li>
{{entry}}
</li>
{{/each}}
</ul>Visit http://localhost:4200 to see your list of favorite locations.
Cardstack projects can be deployed to any major cloud provider. In this tutorial, we'll show you how to deploy to Azure or Heroku. Since we didn't add authentication into this app yet, keep in mind that anyone can submit things through your form. To learn about authentication, see the "Learn more" section below.
Azure is a hosting service with broad international support.
If you don't have Azure already, set up an account following these instructions.
Then, to deploy your Card to Heroku, use the following command:
cardstack deploy --to azureHeroku requires minimal configuration and it has a generous free tier that does not require a credit card to use.
If you don't have Heroku already, set up an account following these instructions.
Then, to deploy your Card to Heroku, use the following command:
cardstack deploy --to herokuWhen it's finished, your app's URL will be shown. Visit it to see your app live!
This is just the beginning of what the Card SDK can do. Follow the Cardstack Tutorial and Guides to add features like authentication, routing, integrating with other data sources, caching, and more!