Need help with hooks?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

midwayjs
280 Stars 17 Forks 218 Commits 3 Opened issues

Description

Isomorphic | Zero Api | Using "React Hooks" to develop the back-end

Services available

!
?

Need anything else?

Contributors list

A Faster Full Stack Framework

中文 README

Docs:Getting Started

✨ Features

  • ☁️  Fullstack, the src directory contains front-end and back-end code
  • 🌈  "Zero" Api, import server functions directly into frontend and automatically create API requests.
  • 🌍  Using "React Hooks | Vue composition" to develop the back-end
  • 📦  Front-end Framework agnostic. Current support React / Vue3 / ICE.js
  • ⚙️  Built on Midway, providing full support for Web and Serverless scenarios
  • 🛡  TypeScript Ready

🌰 Demo

backend api & frontend invoke

backend api src/apis/lambda/index.ts

export async function get() {
  return 'Hello Midway Hooks'
}

export async function post(name: string) { return 'Hello ' + name }

frontend src/page/index.tsx

import { get, post } from './apis/lambda'

get().then((message) => { // send GET request to /api/get // Result: Hello Midway Hooks console.log(message) })

post('github').then((message) => { // send Post request to /api/post, HTTP Body is { args: ['github'] } // Result: Hello github console.log(message) })

Using Hooks

backend api src/apis/lambda/index.ts

import { useContext } from '@midwayjs/hooks'

export async function getPath() { // Get HTTP request context by Hooks const ctx = useContext() return ctx.path }

frontend src/page/index.tsx

import { getPath } from './apis/lambda'

getPath().then((path) => { // send GET request to /api/getPath // Result: /api/getPath console.log(path) })

🚀 Quick Start

Please install faas-cli first.

$ npm i @midwayjs/faas-cli -g

Create

React

$ f create [email protected]/midway-hooks-react

Vue:

$ f create [email protected]/midway-hooks-vue3

ICE.js:

$ npm init ice ice-app --template @icedesign/scaffold-midway-faas

Run

$ npm start

Deploy

$ f deploy

Contribute

  1. Fork it!
  2. Create your feature branch:
    git checkout -b my-new-feature
  3. Commit your changes:
    git commit -am 'Add some feature'
  4. Push to the branch:
    git push origin my-new-feature
  5. Submit a pull request :D

We use yarn + lerna to manage the project.

  • install dependencies
$ yarn
  • build
$ yarn build
  • watch
$ yarn watch
  • test
$ yarn test

license

Midway Serverless based MIT licensed.

About

Alibaba Open Source

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.