DEV Community

Discussion on: How to Connect a React App to a Notion Database

Collapse
 
alexeagleson profile image
Alex Eagleson • Edited

Hey there! That's a great question.

The answer is "I did use it!" Plenty of times. Here's some examples:

  • Typescript reminded me that process.env.NOTION_SECRET could be undefined so it lead me to add the error handling that tells the user they need to include an .env file to run the server

  • There's a TS interface on the server called ThingsToLearn which defines the shape of the data being served to the front end

  • Typescript helped a TON with the Notion query payload which comes back in a pretty complex shape, and I can use the @notionhq/client built in types to navigate the API within VS Code rather than having to jump back and forth between the documentation

  • TS also helped all the times I wrote something wrong or stupid and told me to fix it in the moment rather than causing a runtime error, so there's plenty of use of TS that happened in the development of this tutorial that you don't necessarily see in the final product 😉