|
| 1 | +# Getting Started with the iTwin Viewer Template |
| 2 | + |
| 3 | +This project was scaffolded with [degit](https://github.com/Rich-Harris/degit). |
| 4 | + |
| 5 | +## Environment Variables |
| 6 | + |
| 7 | +Prior to running the app, you will need to add OIDC client configuration to the variables in the .env file: |
| 8 | + |
| 9 | +``` |
| 10 | +# ---- Authorization Client Settings ---- |
| 11 | +IMJS_AUTH_CLIENT_CLIENT_ID="" |
| 12 | +IMJS_AUTH_CLIENT_REDIRECT_URI="" |
| 13 | +IMJS_AUTH_CLIENT_LOGOUT_URI="" |
| 14 | +IMJS_AUTH_CLIENT_SCOPES="" |
| 15 | +``` |
| 16 | + |
| 17 | +- You can generate a [test client](https://developer.bentley.com/tutorials/web-application-quick-start/#3-register-an-application) to get started. |
| 18 | + |
| 19 | +- Viewer expects the `itwin-platform` scope to be set. |
| 20 | + |
| 21 | +- The application will use the path of the redirect URI to handle the redirection, it must simply match what is defined in your client. |
| 22 | + |
| 23 | +- When you are ready to build a production application, [register here](https://developer.bentley.com/register/). |
| 24 | + |
| 25 | +You should also add a valid iTwinId and iModelId for your user in the this file: |
| 26 | + |
| 27 | +``` |
| 28 | +# ---- Test ids ---- |
| 29 | +IMJS_ITWIN_ID = "" |
| 30 | +IMJS_IMODEL_ID = "" |
| 31 | +``` |
| 32 | + |
| 33 | +- For the IMJS_ITWIN_ID variable, you can use the id of one of your existing iTwins. You can obtain their ids via the [iTwin REST APIs](https://developer.bentley.com/apis/itwins/operations/get-itwin/). |
| 34 | + |
| 35 | +- For the IMJS_IMODEL_ID variable, use the id of an iModel that belongs to the iTwin that you specified in the IMJS_ITWIN_ID variable. You can obtain iModel ids via the [iModel REST APIs](https://developer.bentley.com/apis/imodels-v2/operations/get-imodel-details/). |
| 36 | + |
| 37 | +- Alternatively, you can [generate a test iModel](https://developer.bentley.com/tutorials/web-application-quick-start/#4-create-an-imodel) to get started without an existing iModel. |
| 38 | + |
| 39 | +- If at any time you wish to change the iModel that you are viewing, you can change the values of the iTwinId or iModelId query parameters in the url (i.e. localhost:3000?iTwinId=myNewITwinId&iModelId=myNewIModelId) |
| 40 | + |
| 41 | +## Available Scripts |
| 42 | + |
| 43 | +In the project directory, you can run: |
| 44 | + |
| 45 | +### `npm install` |
| 46 | + |
| 47 | +Installs all the dependencies listed in your package.json. |
| 48 | + |
| 49 | +### `npm start` |
| 50 | + |
| 51 | +Runs the app in the development mode.\ |
| 52 | +It automatically opens [http://localhost:3000](http://localhost:3000) in your default browser. |
| 53 | + |
| 54 | +The page will reload if you make edits.\ |
| 55 | + |
| 56 | +### `npm run build` |
| 57 | + |
| 58 | +Builds the app for production to the `dist` folder.\ |
| 59 | +It bundles your code in production mode and applies optimizations for best performance. |
| 60 | + |
| 61 | +The build is minified and the filenames include the hashes.\ |
| 62 | +Your app is ready to be deployed! |
| 63 | + |
| 64 | +See the section about [deployment](https://vite.dev/guide/static-deploy.html) for more information. |
| 65 | + |
| 66 | +### `npm run preview` |
| 67 | + |
| 68 | +Once you have built the app using `npm run build` you may test it locally by running this command. |
| 69 | + |
| 70 | +This will boot up a local static web server that serves the files from `dist` at [http://localhost:3000](http://localhost:3000). |
| 71 | + |
| 72 | +### `npm run lint` |
| 73 | + |
| 74 | +Runs ESLint on all source files to check for code style issues and potential errors. |
| 75 | + |
| 76 | +## Next Steps |
| 77 | + |
| 78 | +- [iTwin Viewer options](https://www.npmjs.com/package/@itwin/web-viewer-react) |
| 79 | + |
| 80 | +- [Extending the iTwin Viewer](https://developer.bentley.com/tutorials/itwin-viewer-hello-world/) |
| 81 | + |
| 82 | +- [Using the iTwin Platform](https://developer.bentley.com/) |
| 83 | + |
| 84 | +- [iTwin Developer Program](https://www.youtube.com/playlist?list=PL6YCKeNfXXd_dXq4u9vtSFfsP3OTVcL8N) |
0 commit comments